Last active
January 18, 2018 22:36
-
-
Save frozeman/c83cc820fabb80175fb166458c3217e0 to your computer and use it in GitHub Desktop.
Test RPC in node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
- $ 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