BitcoinJS: JavaScript Bitcoin library for applications
A TypeScript-based Bitcoin library providing cryptographic functions and transaction handling for Node.js and browsers.
Learn more about BitcoinJS
BitcoinJS is a comprehensive JavaScript library that implements Bitcoin protocol functionality for both Node.js and browser environments. The library is written in TypeScript and provides APIs for creating transactions, managing addresses, handling cryptographic operations, and working with Bitcoin data structures. It uses tiny-secp256k1 for elliptic curve operations and implements RFC6979 for secure nonce generation. The library is commonly used for building Bitcoin wallets, payment processors, and blockchain applications that require Bitcoin protocol integration.
Cross-Platform Compatibility
Runs natively in both Node.js and browser environments through browserify compilation. Maintains consistent API across different JavaScript runtime environments.
Modular Architecture
Separates key management libraries (ECPair, bip32) from core functionality to reduce bundle size. Allows developers to include only required components for their specific use case.
Comprehensive Test Coverage
Maintains over 95% test coverage with extensive validation of Bitcoin protocol implementations. Includes continuous integration testing across multiple Node.js versions.
const bitcoin = require('bitcoinjs-lib');
const ECPair = require('ecpair');
// Create a key pair
const keyPair = ECPair.makeRandom();
const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey });
// Create a new transaction builder
const psbt = new bitcoin.Psbt({ network: bitcoin.networks.testnet });
// Add an input (previous transaction output)
psbt.addInput({
hash: 'e9b542c176808992facac58c46e36ccd2b2e0c7ae0b5c2e4e6b8f0a6e8b5c2d1',
index: 0,
witnessUtxo: {
script: bitcoin.address.toOutputScript(address, bitcoin.networks.testnet),
value: 100000 // satoshis
}
});
// Add an output
psbt.addOutput({
address: 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx',
value: 90000 // leaving 10000 satoshis for fee
});
// Sign the transaction
psbt.signInput(0, keyPair);
psbt.validateSignaturesOfInput(0);
psbt.finalizeAllInputs();
// Extract the transaction
const tx = psbt.extractTransaction();
console.log('Transaction hex:', tx.toHex());
console.log('Transaction ID:', tx.getId());Related Repositories
Discover similar tools and frameworks used by developers
Freqtrade
Python trading bot with backtesting, strategy optimization, and live trading across crypto exchanges.
Uniswap V3 Core
Core smart contracts for the Uniswap V3 decentralized exchange protocol on Ethereum.
Chainlink
Node software for operating in Chainlink's decentralized oracle network, connecting blockchain smart contracts to real-world data.
Aave V3 Core
Smart contracts for Aave Protocol V3, a decentralized liquidity market for lending and borrowing cryptocurrencies.
Cosmos SDK
Open-source framework for building customizable Layer 1 blockchains with native interoperability support.