{"id":18171,"library":"bitcore-lib","title":"Bitcore Library","description":"A pure and powerful JavaScript Bitcoin library providing core Bitcoin primitives such as addresses, transactions, HD keys (BIP32), and message signing. Current stable version is 10.10.7. Maintained as part of the Bitcore ecosystem by BitPay/Bitcore, it is primarily used for building Bitcoin-related Node.js applications. It offers a comprehensive API for creating and parsing transactions, managing keys, and interacting with the Bitcoin network. Key differentiators include full support for BIP21, BIP32, BIP37, and BIP69, and its integration with the Bitcore full node and Insight block explorer.","status":"active","version":"10.10.7","language":"javascript","source_language":"en","source_url":"https://github.com/bitpay/bitcore#master","tags":["javascript","bitcoin","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment"],"install":[{"cmd":"npm install bitcore-lib","lang":"bash","label":"npm"},{"cmd":"yarn add bitcore-lib","lang":"bash","label":"yarn"},{"cmd":"pnpm add bitcore-lib","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Big number arithmetic for Bitcoin values and EC operations.","package":"bn.js","optional":false},{"reason":"Elliptic curve cryptography (secp256k1).","package":"elliptic","optional":false},{"reason":"Base58 encoding for Bitcoin addresses and keys.","package":"bs58","optional":false},{"reason":"Message signing and verification (peer dependency).","package":"bitcore-message","optional":true}],"imports":[{"note":"ESM default import; if using CommonJS, use require('bitcore-lib').default.","wrong":"const bitcore = require('bitcore-lib')","symbol":"bitcore","correct":"import bitcore from 'bitcore-lib'"},{"note":"Named export for PrivateKey.","wrong":"import PrivateKey from 'bitcore-lib/PrivateKey'","symbol":"PrivateKey","correct":"import { PrivateKey } from 'bitcore-lib'"},{"note":"Named export; CommonJS users should destructure from the module.","wrong":"const Transaction = require('bitcore-lib').Transaction","symbol":"Transaction","correct":"import { Transaction } from 'bitcore-lib'"},{"note":"Do not import from direct path; use the package root.","wrong":"import Address from 'bitcore-lib/lib/address'","symbol":"Address","correct":"import { Address } from 'bitcore-lib'"}],"quickstart":{"code":"import bitcore from 'bitcore-lib';\n\n// Generate a new private key\nconst privateKey = new bitcore.PrivateKey();\n\n// Derive the public key and address\nconst publicKey = privateKey.toPublicKey();\nconst address = publicKey.toAddress();\n\nconsole.log('Private Key:', privateKey.toString());\nconsole.log('Address:', address.toString());\n\n// Create a simple transaction (unsigned)\nconst utxo = {\n  address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',\n  txId: 'a477af6b2667c29670467e4e0728b685ee07b240235771b3181b3c3c0f3f3a0b',\n  outputIndex: 0,\n  script: '76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac',\n  satoshis: 10000\n};\n\nconst tx = new bitcore.Transaction()\n  .from(utxo)\n  .to('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2', 9000)\n  .change(address)\n  .fee(1000)\n  .sign(privateKey);\n\nconsole.log('Raw transaction:', tx.toString());","lang":"typescript","description":"Generate a key pair, create and sign a Bitcoin transaction from a UTXO."},"warnings":[{"fix":"Use named imports like import { PrivateKey } from 'bitcore-lib' instead of bitcore.PrivateKey.","message":"v8.0.0 removed the 'bitcore' namespace; methods are now top-level exports.","severity":"breaking","affected_versions":">=8.0.0 <10.0.0"},{"fix":"Use import bitcore from 'bitcore-lib' or const bitcore = require('bitcore-lib').default.","message":"v10.0.0 changed default ESM module; require() no longer works without .default.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Use bitcore.HDKey.fromExtendedKey() instead.","message":"bitcore.HDPublicKey and bitcore.HDPrivateKey are deprecated in favor of bitcore.HDKey.","severity":"deprecated","affected_versions":">=9.0.0"},{"fix":"Call sign() only after all inputs/outputs are set.","message":"Transaction signing mutates the Transaction object; always sign last.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install bitcore-lib","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'bitcore-lib'"},{"fix":"Ensure only one version of bitcore-lib is installed; use npm dedupe or check package.json.","cause":"Multiple instances of bitcore-lib loaded (e.g., via peer dependencies).","error":"TypeError: Right-hand side of 'instanceof' is not an object"},{"fix":"Provide a valid hex string (e.g., raw transaction) or use Buffer.from(hex, 'hex').","cause":"Hex string passed to Transaction.from() is malformed or has wrong length.","error":"Error: Invalid hex string"},{"fix":"Ensure total(inputs) = total(outputs) + fee. Check utxo.satoshis and .to() amounts.","cause":"UTXO satoshis provided do not equal output satoshis plus fee.","error":"Error: Transaction input satoshis do not add up to the outputs"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}