How can I check the latest block height of the chain?

For the moment, you can query a node that is in sync. Eventually a block explorer will be available.


On testnet, you can query

First, check if the node is in syncing

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' -H "Content-Type: application/json"

If the node is in sync, it will return


Then query for block height

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json"

The response will include the block height in hex. Convert the hex value to a decimal to determine the block height.

Here’s one ugly way to get the block height as a decimal.

printf "%d\n" $(curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" | jq -r ".result")
1 Like