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.

Testnet

On testnet, you can query http://146.71.79.179.

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" http://146.71.79.179:8545

If the node is in sync, it will return

{"jsonrpc":"2.0","id":1,"result":false}

Then query for block height

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

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" http://146.71.79.179:8545 | jq -r ".result")
1 Like