Ethereum
eth_getBlockByNumber
eth_getBlockByNumber fetches a block on Ethereum mainnet by its height or by a named tag. Pass a hex height for an exact block, or a tag — latest for the current head, safe for a justified block, finalized for one that's economically irreversible, earliest for genesis. The block object is identical to what eth_getBlockByHash returns: header roots, timestamp, EIP-1559 baseFeePerGas, gas metrics, post-Merge withdrawals, and either full transactions or their hashes. With one block per 12-second slot, walking heights sequentially walks the chain in time. Send requests to https://ethereum.therpc.io/YOUR_API_KEY (chain ID 1, native coin ETH).
Use cases
- Indexing. Step heights one at a time — roughly one new block every 12 seconds — to ingest the chain in order without gaps.
- Live dashboards. Poll
latestto surface the freshest block's timestamp, gas usage, and transaction count on a monitor. - Reorg-safe anchoring. Request the
finalizedblock so any query built on top of it can't be invalidated by a head reorg. - Receipt prep. Pull a block with
includeTransactions=falseto get just the hashes, then fetch all receipts in one shot witheth_getBlockReceipts.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | blockTag | string | Yes | The block to retrieve. |
| 2 | includeTransactions | boolean | Yes | When true, transactions[] contains full transaction objects. When false, only hashes. |
Response
| Type | Description |
|---|---|
| object | null | Same block object as eth_getBlockByHash. Returns null if the block does not exist. |
Example request
Try it live in the Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block number is malformed or block tag is unrecognised. |
Common pitfalls
- The second argument must be a JSON boolean, not the string
"true". Quoted, it gets misread and you may silently receive hashes when you wanted full transactions. - Don't loop
eth_getTransactionReceiptover a block's transactions when you need them all — oneeth_getBlockReceiptscall returns every receipt and saves you dozens of round-trips. - A busy mainnet block with
includeTransactions=truecan run 1–2 MB. If you're only after metadata, request hashes only and hydrate transactions selectively.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111
See also
Parameters
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"
true = full tx objects, false = tx hashes only