Get the current block number:
curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "eth_blockNumber","params": []}' http://localhost:4000/api/eth-rpc
Fetches the number of the most recent block.
Request:
{
"id": 0,
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": []
}
Method: POST
Get the balance of an address:
curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "eth_getBalance","params": ["0x0000000000000000000000000000000000000007", "latest"]}' http://localhost:4000/api/eth-rpc
Fetches the balance of the given address.
Note: The earliest
parameter will not work as expected currently because genesis block balances are not imported.
Request:
{
"id": 0,
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": [
"0x0000000000000000000000000000000000000007",
"latest"
]
}
Method: POST
Get logs from the blockchain:
curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "eth_getLogs","params": [{"address": "0xc78Be425090Dbd437532594D12267C5934Cc6c6f", "paging_options": {"logIndex": "3D", "blockNumber": "6423AC", "transactionIndex": 53}, "fromBlock": "earliest", "toBlock": "latest", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]}' http://localhost:4000/api/eth-rpc
Fetches logs from the blockchain.
Note: This method will never return more than 1000 log entries. Use pagination options to request subsequent pages.
Request:
{
"id": 0,
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [
{
"address": "0xc78Be425090Dbd437532594D12267C5934Cc6c6f",
"paging_options": {
"logIndex": "3D",
"blockNumber": "6423AC",
"transactionIndex": 53
},
"fromBlock": "earliest",
"toBlock": "latest",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
]
}
]
}
Method: POST
To ensure a smooth integration and to maximize the utility of the ETH RPC API, here are some suggestions and hints: