Updated on 2024-11-14 GMT+08:00

eth_getBlockByHash

Introduction

This API returns information about the block by block hash. It consumes 47 CUs.

Parameter Description

Parameter

Type

Description

Block hash

String

The hash of a block.

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_getBlockByHash","params":["0x81e807e7a6031d9f103eeee2a2edc5994c3432ee1e3227c66ff78eef30ea1dec",false],"id":1,"jsonrpc":"2.0"}'