eth_getBlockByNumber — Ethereum JSON-RPC
Returns information about a block on the Ethereum chain, selected by block number or by a named block tag.
https://triport.io/eth- Network
- Ethereum
- Scope
- eth_read_rpc
- Auth
- x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
- Rate limit
- free 10 RPS sustained · up to 20 burst · basic 20 RPS sustained · up to 40 burst · pro 100 RPS sustained · up to 200 burst · business 250 RPS sustained · up to 500 burst; Burst capacity
Endpoint and plans: Ethereum RPC endpoint.
eth_getBlockByNumber returns the full block object for a given block, identified
either by a 0x-prefixed hexadecimal block number or by one of the supported
named tags. It is the standard way to read a historical or current block,
including its header fields and its list of transactions.
The second parameter controls how much transaction detail comes back. When
fullTransactions is false, the transactions array contains only transaction
hashes (cheaper, smaller payload). When it is true, the array contains the
fully expanded transaction objects for every transaction in the block.
If no block matches the requested number or tag — for example a height that has
not been produced yet — the method returns null rather than an error. Always
handle the null case before reading fields off the result.
Parameters
Pass a positional array of exactly two elements.
blockParameterstringrequired0x-prefixed hex block number (e.g. 0x149e2c1) or one of the named tags: latest, earliest, pending, safe, finalized.fullTransactionsbooleanrequiredtrue, returns full transaction objects in transactions. If false, returns only transaction hashes.Response
Response fields
| Field | Type | Description |
|---|---|---|
number | string | Block number as a 0x-prefixed hex string. null for pending blocks. |
hash | string | 32-byte block hash. null for pending blocks. |
parentHash | string | Hash of the parent block. |
nonce | string | 8-byte proof-of-work nonce. null for pending blocks. |
sha3Uncles | string | SHA3 of the uncles data in the block. |
logsBloom | string | Bloom filter for the logs in the block. null for pending blocks. |
transactionsRoot | string | Root of the transaction trie. |
stateRoot | string | Root of the final state trie. |
receiptsRoot | string | Root of the receipts trie. |
miner | string | Address of the block's fee/coinbase recipient. |
difficulty | string | Block difficulty (0x0 post-merge). |
totalDifficulty | string | Total difficulty of the chain up to this block. |
extraData | string | Extra data field of the block. |
size | string | Block size in bytes, hex-encoded. |
gasLimit | string | Maximum gas allowed in the block. |
gasUsed | string | Total gas used by all transactions in the block. |
baseFeePerGas | string | Base fee per gas (post-EIP-1559 blocks). |
timestamp | string | Unix timestamp of block collation, hex-encoded. |
transactions | array | Transaction hashes (when fullTransactions is false) or full transaction objects (when true). |
uncles | array | Array of uncle block hashes. |
The full result is null when no block matches the requested number or tag.
Errors
| Code | Meaning | When it happens |
|---|---|---|
401 | trial_expired | The account's trial period has ended. |
429 | rate_limited | The per-tier RPS limit was exceeded. Back off and retry. |
See errors.md for the full error envelope and handling guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://triport.io/eth", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_getBlockByNumber",
params: ["latest", false],
}),
});
const { result } = await res.json();
if (result === null) {
console.log("block not found");
} else {
console.log("block", parseInt(result.number, 16), "tx count:", result.transactions.length);
}Notes
- All numeric block fields (
number,gasUsed,timestamp, etc.) are hex strings — convert with base 16 before arithmetic. - A
nullresult is normal, not an error: it means the requested block does not exist yet (e.g. a future height). Check fornullbefore dereferencing. - Setting
fullTransactionstotruesubstantially increases the response size on busy blocks; preferfalsewhen you only need transaction hashes. eth_getBlockByNumberis available on the Free trial (eth_read_rpccategory). Rate limiting is RPS-per-tier with burst; there is no daily quota. An HTTP429rate_limitederror means you should back off and retry shortly.- To find the current chain head before requesting a concrete block, call
eth_blockNumber. To look a block up by its hash instead
of its number, use
eth_getBlockByHash.