Updated on 2023-12-06 GMT+08:00

eth_getBlockByNumber

Introduction

This API returns information about the block by block number. It consumes 21 CUs.

Parameter Description

Parameter

Type

Description

Block number

String

A hexadecimal block number, or the string (earliest, latest, or pending).

Transaction details

Bool

If true, it returns the detail of each transaction. If false, it returns only the hashes of the transactions.

Return Value

  • Object: A block object with the following fields, or null when no block was found:
    • number: the block number of the requested block, encoded as hexadecimal. It is null if the block is pending.
    • hash: the hash of the block. It is null if the block is pending.
    • parentHash: the hash of the parent block.
    • nonce: the hash used to demonstrate proof-of-work. It is null if the block is pending.
    • sha3Uncles: SHA3 of the uncles data in the block.
    • logsBloom: the bloom filter for the logs of the block. It is null if the block is pending.
    • transactionsRoot: the root of the transaction trie of the block.
    • stateRoot: the root of the final state trie of the block.
    • receiptsRoot: the root of the receipts trie of the block.
    • miner: the address of the miner receiving the reward.
    • difficulty: the difficulty for this block.
    • totalDifficulty: the total difficulty of the chain until this block.
    • extraData: the "extra data" field of this block.
    • size: the size of this block in bytes.
    • gasLimit: the maximum gas allowed in this block.
    • gasUsed: the total used gas by all transactions in this block.
    • timestamp: the Unix timestamp for when the block was collated.
    • transactions: an array of transaction objects, or 32-bytes transaction hashes, depending on the last given parameter.
    • uncles: an array of uncle hashes.

Request

curl https://your-http-endpoint/v1/<API-KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"method":"eth_getBlockByNumber","params":["0xc5043f",false],"id":1,"jsonrpc":"2.0"}'