Skip to content

Instantly share code, notes, and snippets.

@frozeman frozeman/rpc-test.js
Last active Jan 18, 2018

Embed
What would you like to do?
Test RPC in node.js
/*
- $ geth --shh
- install node.js and npm
- $ mkdir testFolder
- $ npm install oboe
- $ node
- copy the code below
- exceute: send('eth_blockNumber', []);
*/
var oboe = require('oboe')
var net = require('net');
var client = net.createConnection("/Users/youruser/Library/Ethereum/geth.ipc"); // path for Mac, linux is ~/.ethereum/geth.ipc
client.on("connect", function() {
oboe(client)
// called each time a full json object is parsed
.done(function(newHead){
console.log(newHead);
console.log();
});
});
var id = 0;
send = function(method, params){
client.write('{"id": '+ id++ +', "method": "'+ method +'", "params": '+ JSON.stringify(params) +'}');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.