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

chain_getBlockHash - Midnight

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

This method returns the hash of the block at a given block number. If no block number is provided, it returns the hash of the current best block.

Parameters

Parameter
Type
Required
Description

blockNumber

integer | string

No

Block number or null for 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_getBlockHash",
    "params": [
        981031
    ],
    "id": "getblock.io"
}'

Response Example

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

Response Parameters

Field
Type
Description

result

string

Block hash at the requested height

Use Cases

  • Resolving block hashes from heights

  • Cursor-based pagination through historical blocks

  • Bridging between number-based and hash-based block references

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?