on_get_block_hash - Monero

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

This method returns the block hash at a given block height. Note the positional params array (a single-element array containing the height), not the usual object form.

Parameters

Parameter
Type
Required
Description

params[0]

unsigned int

Yes

Block height to look up

Request Example

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

Response Example

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

Response Parameters

Field
Type
Description

result

string

Block hash at the given height

Use Cases

  • Resolving height to hash for historical queries

  • Cursor-based pagination through historical blocks

  • Bridging height-based and hash-based block references

Error Handling

Status Code
Error Message
Cause

404

Not Found

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?