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
Ethers.js
A TypeScript library for Ethereum blockchain interaction, providing wallet management, smart contract interfaces, and provider connections.
Freqtrade
Python trading bot with backtesting, strategy optimization, and live trading across crypto exchanges.
Forge Std
Collection of contracts and libraries that provide testing utilities and cheatcode wrappers for Forge and Foundry.
OpenZeppelin Contracts
A library of audited Solidity components for secure smart contract development on Ethereum and EVM-compatible chains.
Solmate
A collection of gas-optimized Solidity contracts including ERC token implementations and utility libraries.
Related Reading
Guides and comparisons from the Greptile content library
Choosing the Right Code Review Tool: Better Alternatives to Graphite AI
A breakdown of the best alternatives to Graphite for code reviews. Compare AI tools like Trag, open-source solutions like Gerrit, and database-focused platforms like Visual Expert.
What is a sandbox environment? Everything you need to know
A sandbox is an isolated, disposable environment where code can run without touching anything else. Learn how sandboxes work, what teams use them for, how to set one up, and why they matter more now that agents write so much of the code.
How to Evaluate Code Review Tools: The 4 Step Framework
A 4-step framework for evaluating code review tools on large teams with complex codebases: define what you need, build a shortlist, run a live test, and get developer feedback. Plus a shortlist of tools and how to future-proof your review process.
How Greptile Uses Infisical for Secrets Management
How Greptile uses Infisical to keep every secret in one store and let its AI review agents call customer services without ever holding the credentials.