-
Notifications
You must be signed in to change notification settings - Fork 12
JSON RPC API
Cody Burns edited this page Dec 30, 2017
·
1 revision
_ _ _ _
| | (_) | | |
___ _ __ _ _| |_ _ __ _| | ____ ___ __ ___ ______ __| | _____ __
/ __| '_ \| | | | __| '_ \| | |/ /\ \ / / '_ ` _ \______/ _` |/ _ \ \ / /
\__ \ |_) | |_| | |_| | | | | < \ V /| | | | | | | (_| | __/\ V /
|___/ .__/ \__,_|\__|_| |_|_|_|\_\ \_/ |_| |_| |_| \__,_|\___| \_/
| |
|_|
Assuming you start with JSONRPC API enabled (default), then Ethereum's JSON-RPC can be used, e.g.:
$ curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xefa5a1cb68d4fe387a881ebf279d675b03c84088", "latest"],"id":1}' http://127.0.0.1:8545
Sputnik has the web3 Javascript API for interacting with an Ethereum client.
Sputnik doesn't include a JavaScript interpreter but if you want to use an interactive JavaScript console, you can install node and npm and use its console. Once you have node/NPM installed, you'll just need to install the latest Web3 module:
$ npm install web3
From then on you just need to run node and require the Web3 module:
$ node
> Web3 = require("web3")
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
After this point, you'll be able to use the Web3 API from with this environment, e.g.:
> web3.eth.blockNumber
743397
Below is a list of all the supported RPC endpoints by sputnikvm-dev.