bitcore/examples/Rpc.js

33 lines
693 B
JavaScript
Raw Normal View History

2014-02-24 04:06:54 -08:00
'use strict';
2014-03-12 09:08:52 -07:00
var run = function() {
2014-03-12 10:21:23 -07:00
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
var bitcore = require('../bitcore');
var RpcClient = bitcore.RpcClient;
2014-03-12 09:08:52 -07:00
var hash = '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
2014-03-12 09:08:52 -07:00
var config = {
protocol: 'http',
user: 'user',
pass: 'pass',
host: '127.0.0.1',
port: '18332',
};
2014-03-12 09:08:52 -07:00
var rpc = new RpcClient(config);
2014-02-24 04:06:54 -08:00
2014-03-12 09:08:52 -07:00
rpc.getBlock(hash, function(err, ret) {
if (err) {
console.error('An error occured fetching block', hash);
console.error(err);
return;
}
console.log(ret);
});
};
2014-02-24 04:06:54 -08:00
2014-03-12 09:08:52 -07:00
module.exports.run = run;
if (require.main === module) {
run();
}