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

chain_getHeader - Midnight

Example code for the chain_getHeader JSON-RPC method. Complete guide on how to use chain_getHeader JSON-RPC in GetBlock Web3 documentation.

This method returns the header of a block by its hash. Headers contain parent hash, number, state root, extrinsics root, and digest.

Parameters

Parameter
Type
Required
Description

hash

string

No

Block hash to query. Defaults to the current best block

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "chain_getHeader",
    "params": [
        "0x87f5c08ba8334e4ee1642ff9646e94dd46080b71fff03714be8b36f22e481b95"
    ],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "parentHash": "0x86e4c08\u2026",
        "number": "0xef727",
        "stateRoot": "0x9e7c5e\u2026",
        "extrinsicsRoot": "0x56e81f\u2026",
        "digest": {
            "logs": []
        }
    }
}

Response Parameters

Field
Type
Description

result.parentHash

string

Hash of the parent block

result.number

string

Block number (hex)

result.stateRoot

string

State trie root after this block

result.extrinsicsRoot

string

Extrinsics trie root

result.digest

object

Block digest with consensus logs

Use Cases

  • Light client header walks

  • Indexers that need only metadata

  • Verifying parent-chain relationships

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?