How to view latest block number of a geth node in the console?

  • How to get information about the state of the blockchain on a geth node?

    There are mentions of admin.chainSyncStatus in the documentation, but it is undefined on my 1.4.0 node. The admin.nodeInfo shows a hash for the head block, but not the number.

    This information is sort-of available in the log, but that is not an answer.

  • Tjaden Hess

    Tjaden Hess Correct answer

    5 years ago

    eth.blockNumber will give the most recent block your node has processed.

    eth.syncing gives more information, like what the estimated highest current block is.

    var sync = web3.eth.syncing; 
     /* { startingBlock: 300, currentBlock: 312, highestBlock: 512 } */

    Now-a-days, one should `console.log("Syncing is " + await web3.eth.isSyncing());` and `await web3.eth.getBlockNumber()`.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM

Tags used