bitcoin-rpc-promise

A modern promise based node.js library for communicating with Bitcoin daemon.

npm package

NPM version Dependency Status Known Vulnerabilities Downloads FOSSA Status

Install

npm install --save bitcoin-rpc-promise

Usage

Start bitcoin daemon with rpc support:

./bitcoind --server=1 --rpcuser=user --rpcpassword=password

Connect to daemon endpoint and send rpc commands:

const BitcoinRpc = require('bitcoin-rpc-promise');

let btc = new BitcoinRpc('http://user:password@localhost:8332');

// call named wrappers
btc.getBlockHash(100).then(result => {
  console.log(result);
});

// or call named wrappers with all lower case
btc.getblockhash(100).then(result => {
  console.log(result);
});

// or call raw commands
btc.call('getblockhash', 100).then(result => {
  console.log(result);
});

Documentation

Bitcoin Wiki