2.1.6 • Published 6 years ago
bitcoin-rpc-promise v2.1.6
bitcoin-rpc-promise
A modern promise based node.js library for communicating with Bitcoin daemon.
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);
});