For the complete documentation index, see llms.txt. This page is also available as Markdown.

eth_getUncleCountByBlockNumber - Optimism

Example code for the eth_getUncleCountByBlockNumber json-rpc method. Сomplete guide on how to use eth_getUncleCountByBlockNumber json-rpc in GetBlock.io Web3 documentation.

This method returns the number of uncle blocks in a specified block by block number. On Optimism, this always returns 0 since uncles don't exist in the rollup model.

Parameters

Parameter
Type
Description
Required

blockNumber

QUANTITY|TAG

Block number in hex, or 'latest', 'earliest', 'pending'.

Yes

Request Sample

curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
   "jsonrpc": "2.0",
    "method": "eth_getUncleCountByBlockNumber",
  "params": [
    "latest"
  ],
    "id": "getblock.io"
}'

Response

A successful response returns the following:

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x0"
}

Response Parameters

  • id: A unique request identifier, matching the id sent in the request body.

  • jsonrpc: Specifies the use of JSON-RPC version 2.0.

  • result: The uncle count as hexadecimal (always 0x0 on Optimism).

Use Case

The eth_getUncleCountByBlockNumber method is commonly used for:

  • Ethereum compatibility

  • Block structure analysis

Error handling

Status Code
Error Message
Cause

404

Not Found

Missing or invalid ACCESS_TOKEN.

-32602

Invalid argument

  • Invalid block number

Integration with Web3

Last updated

Was this helpful?