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

chain_getHead - Midnight

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

This method returns the hash of the current best (unfinalized) block. For finality-aware applications, prefer chain_getFinalizedHead.

Parameters

  • None

Request Example

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

Response Example

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

Response Parameters

Field
Type
Description

result

string

Hash of the current best block

Use Cases

  • Polling for the latest block as a starting point

  • Low-latency applications that prefer fresh-but-unfinalized state

  • Health checks and tip monitoring

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?