Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: eth_getBlockState - returns chainId, block number, block timestamp and stateId #629

Open
sambacha opened this issue Feb 19, 2025 · 0 comments

Comments

@sambacha
Copy link

eth_getBlockState

Motivation

DApps will request chainId and blocknumber continuously (e.g. look at uniswap dapp network console). There is not any RPC methods that return ChainId information outside of eth_chainId. This seems useful, so include it in block number and block timestamp response and we got this.

Method Name

eth_getBlockState

Description

Returns the chain ID, block number, and block state and block timestamp for the specified block parameter.

Note

Need to add block.timestamp in response and request, just thought of it as I am typing this meow

Parameters

  1. blockParameter - An object containing one of the following block state identifiers:

    • { "blockNumber": "earliest" } - Earliest/genesis block
    • { "blockNumber": "latest" } - Latest canonical block
    • { "blockNumber": "pending" } - Pending state/transactions
    • { "blockNumber": "safe" } - Most recent safe block
    • { "blockNumber": "finalized" } - Most recent finalized block

Returns

Object - A block state object containing:

  • chainId: STRING - The chain ID in hexadecimal format
  • blockNumber: STRING - The block number in hexadecimal format
  • blockState: STRING - One of: "earliest", "latest", "pending", "safe", "finalized"

Example Request

{
  "jsonrpc": "2.0",
  "method": "eth_getBlockState",
  "params": [
    {
      "blockNumber": "latest"
    }
  ],
  "id": 1
}

Example Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "chainId": "0x1",
    "blockNumber": "0xf4240",
    "blockState": "latest"
  }
}

Error Codes

Code Message Description
-32700 Parse error Invalid JSON
-32600 Invalid Request JSON is not a valid request object
-32601 Method not found Method does not exist
-32602 Invalid params Invalid method parameters
-32603 Internal error Internal JSON-RPC error

Specification Notes

  1. EIP-1898 Compliance

    • The block parameter MUST be specified as an object
    • The object MUST contain a blockNumber field
    • The value MUST be one of the specified string literals
  2. EIP-1474 Compliance

    • Method name follows the eth_ namespace convention
    • Adheres to standard JSON-RPC 2.0 format
    • All numeric values are hexadecimal encoded
    • Error codes follow standard ranges
  3. Additional Requirements

    • The response MUST include all three fields: chainId, blockNumber, and blockState
    • Chain ID MUST be returned in hexadecimal format
    • Block number MUST be returned in hexadecimal format
    • Block state MUST be one of the five specified string literals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant