bitcore/examples/Rpc.js

33 lines
693 B
JavaScript

'use strict';
var run = function() {
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var RpcClient = bitcore.RpcClient;
var hash = '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
var config = {
protocol: 'http',
user: 'user',
pass: 'pass',
host: '127.0.0.1',
port: '18332',
};
var rpc = new RpcClient(config);
rpc.getBlock(hash, function(err, ret) {
if (err) {
console.error('An error occured fetching block', hash);
console.error(err);
return;
}
console.log(ret);
});
};
module.exports.run = run;
if (require.main === module) {
run();
}