ETH RPC

The Blockscout ETH RPC API supports 3 methods in the exact format specified for Ethereum nodes, see the Ethereum JSON-RPC Specification for more details. These methods are provided for your convenience. In general, custom RPC methods are recommended.

The following 3 methods are supported:

  • eth_blockNumber

  • eth_getBalance

  • eth_getLogs

In the following examples we use the Ethereum mainnet with the base instance url https://blockscout.com/eth/mainnet. When sending a request add /api/eth-rpc to the end of the base url.

eth_blockNumber

Returns the latest block number in the chain in hexidecimal format. No params are needed. Type: POST

Example

// Request
curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' https://blockscout.com/eth/mainnet/api/eth-rpc
// Response
{
  "jsonrpc": "2.0",
  "result": "0xfa0b0e",
  "id": 0
}

eth_getBalance

Returns the balance of a given address in wei. Note the earliest parameter does not work as expected because genesis block balances are not currently imported. Parameters are required.

Required Parameters

Example

// Request
curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_getBalance","params":["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","latest"]}' https://blockscout.com/eth/mainnet/api/eth-rpc
// Response
{
  "jsonrpc": "2.0",
  "result": "0x1d863bf76508104fb", //34039260923474019579
  "id": 0
}

eth_getLogs

Returns an array of logs matching a specified filter object. Params are optional based on data you want to receive. From more information, see this post on eth_getLogs.

Note: Never returns more than 1000 log entries. You can use pagination options to request the next page. Pagination options params: {"logIndex": "3D", "blockNumber": "6423AC"} which include parameters from the last log received from the previous request. These three parameters are required for pagination.

Parameters

Example Query

//Request
curl -H "content-type: application/json" -X POST --data 
'{"id":0,"jsonrpc":"2.0","method":"eth_getLogs","params":
[{"address":"0xc78Be425090Dbd437532594D12267C5934Cc6c6f","paging_options":
{"logIndex":"3D","blockNumber":"6423AC"},"fromBlock":"earliest","toBlock":"latest","topics":
["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]}'
https://blockscout.com/eth/mainnet/api/eth-rpc

Last updated