eth_getHeaderByNumber
JSON-RPC method returns the block header information for a given block number. This method provides header data without the transaction list, offering a lightweight way to access block metadata and is more efficient than fetching the full block when only header information is needed.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
- block_number (string) — The block number as a hexadecimal string, or one of the string tags: “latest”, “earliest”, or “pending”
Response
The method returns block header information ornull
if the block doesn’t exist.
Response structure
Block header fields:hash
— The block hashparentHash
— Hash of the parent blocknumber
— The block numbertimestamp
— The unix timestamp when the block was collatedgasLimit
— The maximum gas allowed in this blockgasUsed
— The total gas used by all transactions in this blockdifficulty
— The difficulty for this blocktotalDifficulty
— The total difficulty of the chain until this blockminer
— The address of the beneficiary to whom the mining rewards were givennonce
— The nonce used to generate this blocksha3Uncles
— SHA3 of the uncles data in the blocklogsBloom
— The bloom filter for the logs of the blocktransactionsRoot
— The root of the transaction trie of the blockstateRoot
— The root of the final state trie of the blockreceiptsRoot
— The root of the receipts trie of the block
Block number tags
Available tags:"latest"
— The most recent block in the chain"earliest"
— The genesis block (block 0)"pending"
— The pending state/transactions
Usage example
Basic implementation
Example request
Shell
Use cases
Theeth_getHeaderByNumber
method is useful for applications that need to:
- Efficient block monitoring: Monitor new blocks without downloading full transaction data
- Chain synchronization: Implement lightweight chain synchronization mechanisms
- Block analytics: Analyze block metadata, timing, and gas usage patterns
- Network monitoring: Monitor network health and block production rates
- Mining analytics: Track mining difficulty, block times, and miner statistics
- Chain validation: Validate blockchain integrity and block relationships
- Performance optimization: Reduce bandwidth usage when only header data is needed
- Block explorers: Build efficient block explorer interfaces
- DeFi applications: Monitor block timing for time-sensitive operations
- Gas analysis: Analyze gas usage patterns across blocks
- Network statistics: Generate blockchain statistics and metrics
- Timestamp tracking: Track block timestamps for time-based operations
- Parent-child relationships: Analyze block relationships and chain structure
- Difficulty analysis: Monitor mining difficulty adjustments
- State root tracking: Track state changes across blocks without transaction details
Body
application/json