0 votes
1 view
in Blockchain by (7k points)

Parity UI displays current block number at the bottom, but if UI is not enabled, then how do we find the current block number?

Is there a way to find current block number

using JSONRPC ?
Is it stored somewhere in basepath?
Note: If anyone can find proper tags, please update it! Currently there is no tag for parity.

1 Answer

0 votes
by (14.5k points)

To get the latest block number over RPC, you can call the 'eth_blockNumber' method. 

See this from the https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber: 

// Request

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}'

// Result

{

  "id":83,

  "jsonrpc": "2.0",

  "result": "0x4b7" // 1207

}

Also, there are other higher-level APIs like web3.js or web3.py. These allow users to use web3.eth.blockNumber to get the latest block number. These APIs generally work in native types rather than hex strings.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...