curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": [
"0x2ce91ae0ed242b4b78b432a45b982fb81a414d6b04167762ed3c7446710a4b8e",
"0x0"
],
"id": 1
}
'{
"jsonrpc": "2.0",
"id": 1,
"result": null
}curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": [
"0x2ce91ae0ed242b4b78b432a45b982fb81a414d6b04167762ed3c7446710a4b8e",
"0x0"
],
"id": 1
}
'{
"jsonrpc": "2.0",
"id": 1,
"result": null
}eth_getUncleByBlockHashAndIndex JSON-RPC method returns information about an uncle block by block hash and uncle index position. Uncle blocks are valid blocks that were not included in the main chain but are referenced by the main chain blocks for network security.
null if no uncle exists at the specified index.
null if no uncle exists at the specified index// Get uncle block by hash and index
const getUncleByBlockHashAndIndex = async (blockHash, uncleIndex) => {
const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getUncleByBlockHashAndIndex',
params: [blockHash, uncleIndex],
id: 1
})
});
const data = await response.json();
return data.result;
};
// Check for uncles in a block
const checkBlockUncles = async (blockHash) => {
const uncles = [];
let index = 0;
while (true) {
const uncle = await getUncleByBlockHashAndIndex(
blockHash,
`0x${index.toString(16)}`
);
if (uncle === null) {
break;
}
uncles.push(uncle);
index++;
}
return uncles;
};
// Usage
const blockHash = '0x2ce91ae0ed242b4b78b432a45b982fb81a414d6b04167762ed3c7446710a4b8e';
checkBlockUncles(blockHash).then(uncles => {
console.log(`Found ${uncles.length} uncles in block`);
uncles.forEach((uncle, i) => {
console.log(`Uncle ${i}:`, uncle);
});
});
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": [
"0x2ce91ae0ed242b4b78b432a45b982fb81a414d6b04167762ed3c7446710a4b8e",
"0x0"
],
"id": 1
}' \
https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm
eth_getUncleByBlockHashAndIndex method is useful for applications that need to:
JSON-RPC version
2.0 The RPC method name
eth_getUncleByBlockHashAndIndex Parameters: [block_hash, uncle_index]
Request identifier
Was this page helpful?