Skip to content

JSON RPC API

Cody Burns edited this page Dec 30, 2017 · 1 revision
                         _         _ _                              _            
                        | |       (_) |                            | |           
         ___ _ __  _   _| |_ _ __  _| | ____   ___ __ ___ ______ __| | _____   __
        / __| '_ \| | | | __| '_ \| | |/ /\ \ / / '_ ` _ \______/ _` |/ _ \ \ / /
        \__ \ |_) | |_| | |_| | | | |   <  \ V /| | | | | |    | (_| |  __/\ V / 
        |___/ .__/ \__,_|\__|_| |_|_|_|\_\  \_/ |_| |_| |_|     \__,_|\___| \_/  
            | |                                                                  
            |_|                                                                  

JSON-RPC API

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

JavaScript Console

Sputnik has the web3 Javascript API for interacting with an Ethereum client.

Node.js CLI Console

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

Supported RPC Endpoints

Below is a list of all the supported RPC endpoints by sputnikvm-dev.

web3_clientVersion

web3_sha3

net_version

net_peerCount

net_listening

eth_protocolVersion

eth_syncing

eth_coinbase

eth_mining

eth_hashrate

eth_gasPrice

eth_accounts

eth_blockNumber

eth_getBalance

eth_getStorageAt

eth_getTransactionCount

eth_getBlockTransactionCountByHash

eth_getBlockTransactionCountByNumber

eth_getUncleCountByBlockHash

eth_getUncleCountByBlockNumber

eth_getCode

eth_sign

eth_sendTransaction

eth_sendRawTransaction

eth_call

eth_estimateGas

eth_getBlockByHash

eth_getBlockByNumber

eth_getTransactionByHash

eth_getTransactionByBlockHashAndIndex

eth_getTransactionByBlockNumberAndIndex

eth_getTransactionReceipt

eth_getUncleByBlockHashAndIndex

eth_getUncleByBlockNumberAndIndex

eth_getCompilers

eth_newFilter

eth_newBlockFilter

eth_newPendingTransactionFilter

eth_uninstallFilter

eth_getFilterChanges

eth_getFilterLogs

eth_getLogs