Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
bitcore
✓ import bitcore from 'bitcore-lib'
✗ const bitcore = require('bitcore-lib')
ESM default import; if using CommonJS, use require('bitcore-lib').default.
PrivateKey
✓ import { PrivateKey } from 'bitcore-lib'
✗ import PrivateKey from 'bitcore-lib/PrivateKey'
Named export for PrivateKey.
Transaction
✓ import { Transaction } from 'bitcore-lib'
✗ const Transaction = require('bitcore-lib').Transaction
Named export; CommonJS users should destructure from the module.
Address
✓ import { Address } from 'bitcore-lib'
✗ import Address from 'bitcore-lib/lib/address'
Do not import from direct path; use the package root.
Generate a key pair, create and sign a Bitcoin transaction from a UTXO.
import bitcore from 'bitcore-lib';
// Generate a new private key
const privateKey = new bitcore.PrivateKey();
// Derive the public key and address
const publicKey = privateKey.toPublicKey();
const address = publicKey.toAddress();
console.log('Private Key:', privateKey.toString());
console.log('Address:', address.toString());
// Create a simple transaction (unsigned)
const utxo = {
address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',
txId: 'a477af6b2667c29670467e4e0728b685ee07b240235771b3181b3c3c0f3f3a0b',
outputIndex: 0,
script: '76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac',
satoshis: 10000
};
const tx = new bitcore.Transaction()
.from(utxo)
.to('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2', 9000)
.change(address)
.fee(1000)
.sign(privateKey);
console.log('Raw transaction:', tx.toString());
Errors
Common errors & fixes
Cannot find module 'bitcore-lib'
Package not installed or not in node_modules.
fixRun npm install bitcore-lib
TypeError: Right-hand side of 'instanceof' is not an object
Multiple instances of bitcore-lib loaded (e.g., via peer dependencies).
fixEnsure only one version of bitcore-lib is installed; use npm dedupe or check package.json.
Error: Invalid hex string
Hex string passed to Transaction.from() is malformed or has wrong length.
fixProvide a valid hex string (e.g., raw transaction) or use Buffer.from(hex, 'hex').
Error: Transaction input satoshis do not add up to the outputs
UTXO satoshis provided do not equal output satoshis plus fee.
fixEnsure total(inputs) = total(outputs) + fee. Check utxo.satoshis and .to() amounts.
Audit
Dependencies
bn.jsrequiredBig number arithmetic for Bitcoin values and EC operations.
ellipticrequiredElliptic curve cryptography (secp256k1).
bs58requiredBase58 encoding for Bitcoin addresses and keys.
bitcore-messageoptionalMessage signing and verification (peer dependency).