bitshares-rpc
v1.0.0
Published
Simple wrapper for the jayson library to make rpc calls to the Bitshares client
Downloads
6
Readme
#Bitshares-rpc
A very simple API wrapper for the excellent jayson library and Q for promises to make an RPC client for Bitshares.
##Installation npm install bitshares-rpc
##Usage var bitshares = require('bitshares-rpc'); var config = require('config.json');
var bitshares_client = bitshares.client({
port: config.port, // Optional - default 1775
hostname: config.hostname, // Optional - default 127.0.0.1
username: config.username,
password: config.password
});
bitshares_client.request('RPC_METHOD', [PARAMS]).then(function(result) {
// Use result
})
.catch(function(error) {
// Handle error
});
RPC_METHOD can by any method found in the Bitshares client.
PARAMS is optional for methods that do not take parameters, if needed it should be an array of parameters.
##Examples
Some specific use cases:
bitshares_client.request('getinfo')
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log(error);
});
bitshares_client.request('blockchain_list_delegates',[10, 10])
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log(error);
});
Chaining with Q:
var Q = require('q');
Q.all([
bitshares_client.request('getinfo'),
bitshares_client.request('blockchain_list_delegates',[10, 10])
])
.then(function(result) {
var getinfo = result[0];
var delegates = result[1];
})
.catch(function(error) {
console.log(error);
})
License
bitshares-rpc is freely distributable under the terms of the MIT license.