get_block_header_by_height - Monero

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

This method returns the header of a block at a given height. Functionally similar to get_block_header_by_hash but indexed by height.

Parameters

Parameter
Type
Required
Description

height

unsigned int

Yes

Height of the block whose header to return

Request Example

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

Response Example

{
    "id": "getblock.io",
    "jsonrpc": "2.0",
    "result": {
        "block_header": {
            "block_size": 5500,
            "depth": 100,
            "difficulty": 294558564173,
            "hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
            "height": 912345,
            "major_version": 7,
            "minor_version": 7,
            "nonce": 1234567890,
            "num_txes": 12,
            "orphan_status": false,
            "prev_hash": "37155cae7d3aa8ca7dc8b9e69e0d1f64b5e3a8b1c2d9e4f5a6b7c8d9e0f1a2b3",
            "reward": 1500000000000,
            "timestamp": 1452793716
        },
        "status": "OK",
        "untrusted": false
    }
}

Response Parameters

Field
Type
Description

result.block_header.height

unsigned int

Block height (echoed back)

result.block_header.hash

string

Block hash at this height

result.block_header.timestamp

unsigned int

Unix timestamp

result.block_header.reward

unsigned int

Coinbase reward in atomic units

Use Cases

  • Resolving header metadata from a known height

  • Block-by-block iteration in indexers

  • Computing block-time intervals

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?