Ethereum

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 latest to surface the freshest block's timestamp, gas usage, and transaction count on a monitor.
  • Reorg-safe anchoring. Request the finalized block so any query built on top of it can't be invalidated by a head reorg.
  • Receipt prep. Pull a block with includeTransactions=false to get just the hashes, then fetch all receipts in one shot with eth_getBlockReceipts.

Parameters

#NameTypeRequiredDescription
1blockTagstringYesThe block to retrieve.
2includeTransactionsbooleanYesWhen true, transactions[] contains full transaction objects. When false, only hashes.

Response

TypeDescription
object | nullSame block object as eth_getBlockByHash. Returns null if the block does not exist.

Example request

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [
"latest",
false
],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock 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_getTransactionReceipt over a block's transactions when you need them all — one eth_getBlockReceipts call returns every receipt and saves you dozens of round-trips.
  • A busy mainnet block with includeTransactions=true can 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

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["latest",false]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.