Skip to content

GregProuty/chainsig-es6-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChainSig.js Simple JavaScript Example

A simple Node.js example demonstrating how to use chainsig.js in a plain JavaScript project without TypeScript.

What This Example Shows

This example demonstrates:

  • ✅ How to import chainsig.js using CommonJS require()
  • ✅ 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

Requirements

  • Node.js (v14 or higher)
  • npm

Quick Start

# Install dependencies
npm install

# Run the example
npm start

What You'll See

The example will display:

  • Available chain adapters
  • Supported blockchains
  • Required parameters for each adapter
  • Contract configuration options
  • Next steps for implementation

Code Structure

  • package.json - Simple CommonJS configuration with chainsig.js dependency
  • index.js - Plain JavaScript code using require() syntax
  • No TypeScript, no transpilation needed!

Key Differences from TypeScript Version

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

Next Steps

  1. Choose your blockchain - Bitcoin, Ethereum, Solana, Cosmos, etc.
  2. Set up chain client - Each chain needs its own client connection
  3. Initialize adapter - Use the appropriate adapter with your configuration
  4. Sign transactions - Use the adapter methods to sign and submit

Example Usage Patterns

Bitcoin

const { BitcoinAdapter } = require('chainsig.js');
// Need: network, contract, btcRpcAdapter

Ethereum

const { EthereumAdapter } = require('chainsig.js');
// Need: publicClient, contract

Solana

const { SolanaAdapter } = require('chainsig.js');
// Need: connection, contract

Perfect For

  • 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!

About

Modern ES6 JavaScript example for chainsig.js with Babel transpilation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published