A simple Node.js example demonstrating how to use chainsig.js in a plain JavaScript project without TypeScript.
This example demonstrates:
- ✅ How to import
chainsig.jsusing CommonJSrequire() - ✅ Accessing all available chain adapters (Bitcoin, Ethereum, Solana, etc.)
- ✅ Exploring supported chains and environments
- ✅ Understanding what's needed to initialize each adapter
- ✅ Working with the published npm package
- Node.js (v14 or higher)
- npm
# Install dependencies
npm install
# Run the example
npm startThe example will display:
- Available chain adapters
- Supported blockchains
- Required parameters for each adapter
- Contract configuration options
- Next steps for implementation
package.json- Simple CommonJS configuration with chainsig.js dependencyindex.js- Plain JavaScript code usingrequire()syntax- No TypeScript, no transpilation needed!
| Simple JS | TypeScript |
|---|---|
const chainsig = require('chainsig.js') |
import * as chainsig from 'chainsig.js' |
| No type annotations | Full TypeScript types |
| No compilation step | Requires ts-node |
| Direct Node.js execution | Transpilation required |
- Choose your blockchain - Bitcoin, Ethereum, Solana, Cosmos, etc.
- Set up chain client - Each chain needs its own client connection
- Initialize adapter - Use the appropriate adapter with your configuration
- Sign transactions - Use the adapter methods to sign and submit
const { BitcoinAdapter } = require('chainsig.js');
// Need: network, contract, btcRpcAdapterconst { EthereumAdapter } = require('chainsig.js');
// Need: publicClient, contractconst { SolanaAdapter } = require('chainsig.js');
// Need: connection, contract- Developers who prefer plain JavaScript
- Projects that don't use TypeScript
- Quick prototyping and testing
- Learning how chainsig.js works
- Integration into existing CommonJS projects
This example proves you can use chainsig.js in any Node.js project without needing TypeScript!