L0vdL0vd

eth_blockNumber

Returns the number of the most recent block.

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}'

Пример ответа

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1936553"
}
Параметры и свой эндпоинт

Параметры

У метода нет параметров.

Возвращает

string Block number, hex.

Когда использовать

Get the latest block number: health checks, polling for new blocks, and choosing a fixed block for consistent reads.

Как читать ответ

Hex integer: parseInt(result, 16).

Советы

  • Read the head once, then pass that number to every call in the same job so all answers come from one consistent state.
  • Cheap, but not free: poll every block time (about 12 seconds on Ethereum), not in a tight loop.

Связанные методы