eth_getUncleByBlockNumberAndIndex
https://api.triport.io/v1/ethereumReturns the uncle (ommer) block at a given index within the block identified by its number or a block tag.
eth_getUncleByBlockNumberAndIndex returns the uncle block (also called an
ommer) at a given position within a parent block. The parent block is
identified by a 0x-prefixed hex block number or a named block tag, and the
uncle is selected by its zero-based index in that block's uncle list. The
returned value is a block header object — uncle headers are stored without
their own transaction bodies, so the transactions and uncles arrays of the
returned object are always empty.
Uncles are a proof-of-work artifact. They only ever appeared on pre-Merge
Ethereum (blocks mined before the September 2022 transition to proof-of-stake).
Since the Merge, no new uncles are produced, so for any post-Merge block this
method always returns null. It remains useful for reading historical
pre-Merge blocks that did include uncles.
If the parent block does not exist, or the uncle index is out of range for that
block, the result is null rather than an error. Always handle the null
case before reading fields off the result. To find how many uncles a block has
before indexing into them, call
eth_getUncleCountByBlockNumber.
Parameters
Pass a two-element positional array.
blockParameterstringrequired0x-prefixed hex block number (e.g. 0xf4240) or a block tag: latest, earliest, pending, safe, or finalized.uncleIndexstringrequired0x-prefixed hex integer (e.g. 0x0 for the first uncle).Response
A pre-Merge block that has an uncle at the requested index returns the uncle's header object:
For any post-Merge block, or when the block or index does not exist, the response is:
{
"jsonrpc": "2.0",
"id": 1,
"result": null
}jsonrpcstring"2.0".idnumberid.resultobject | nullnull if there is no uncle at that index (always null for post-Merge blocks).Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The account's trial period has ended. |
-32003 | 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://api.triport.io/v1/ethereum", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_getUncleByBlockNumberAndIndex",
params: ["0xf4240", "0x0"],
}),
});
const { result } = await res.json();
if (result === null) {
console.log("no uncle at that index (or post-Merge block)");
} else {
console.log("uncle", result.hash, "mined by", result.miner);
}TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
type UncleHeader = { number: string; hash: string; miner: string };
const uncle = await client.ethereum.request<UncleHeader | null>(
"eth_getUncleByBlockNumberAndIndex",
["0xf4240", "0x0"],
);
console.log(uncle ? uncle.hash : "no uncle at that index");Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
uncle = client.ethereum.request(
"eth_getUncleByBlockNumberAndIndex",
["0xf4240", "0x0"],
)
print(uncle["hash"] if uncle else "no uncle at that index")Notes
- Post-Merge blocks always return
null. Uncles are a proof-of-work concept; no uncles have been produced since the Merge. Use this method only against historical pre-Merge blocks. - The returned object is a block header, not a full block: its
transactionsandunclesarrays are always empty. - The uncle index is zero-based:
0x0is the first uncle. Both the block parameter and the index are0x-prefixed hex strings. - An out-of-range index or a non-existent block returns
result: null, not an error — check fornullbefore reading fields. - Numeric fields (
number,difficulty,timestamp, …) are hex strings; convert with base 16 before arithmetic. eth_getUncleByBlockNumberAndIndexis available on the free tier (eth_read_rpccategory). Rate limiting is RPS-per-tier with burst; there is no daily quota. A-32003 rate_limitederror means you should back off and retry shortly.- To count a block's uncles first, use
eth_getUncleCountByBlockNumber. To select
the parent block by hash instead of number, use
eth_getUncleByBlockHashAndIndex.