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.


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 } */
| improve this answer | |

You can use eth.blockNumber as shown below:

> eth.blockNumber

Source: Ethereum Wiki - JavaScript API.

Referring to @Tjaden Hess's answer,

  1. When geth has not started syncing yet:

    > var sync = web3.eth.syncing; 
    > console.log(sync);
  2. After geth has started syncing:

    > var sync = web3.eth.syncing; 
    > console.log(sync);
    [object Object]
    > sync
      currentBlock: 1486592,
      highestBlock: 1488447,
      startingBlock: 1486592
| improve this answer | |
  • Sometimes highestBlock returns: undefined maybe 100 times in a loop until it is able to return a valid number, is it normal? Please note that geth is syncing. @BokkyPooBah – alper Apr 19 '17 at 5:57
