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

getblockheader - Zcash

Example code for the getblockheader JSON-RPC method. Сomplete guide on how to use the getblockheader JSON-RPC method in GetBlock.io Web3 documentation.

This method returns block header data — the fixed 80-byte header plus derived fields — without the full transaction list. Significantly cheaper than getblock when only header data is needed, such as during header-first chain synchronization or SPV-style verification.

Parameters

Parameter
Type
Required
Description

blockhash

string

Yes

Block hash (hex string)

verbose

boolean

No

If true (default), returns a JSON object; if false, returns raw hex-encoded header

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getblockheader",
    "params": [
        "00000000018bb43cadf5b4c8a2e7f9d0e1a6b3c8d5e4f2a1b0c9d8e7f6a5b4c3",
        true
    ],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'getblockheader',
    params: [
        "00000000018bb43cadf5b4c8a2e7f9d0e1a6b3c8d5e4f2a1b0c9d8e7f6a5b4c3",
        true
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

Response

Response Parameters

Parameter
Type
Description

hash

string

Block hash

confirmations

integer

Number of confirmations

height

integer

Block height

version

integer

Block version

merkleroot

string

Merkle root of transactions

blockcommitments

string

Block commitments hash (post-Heartwood)

finalsaplingroot

string

Final Sapling commitment tree state after this block

time

integer

Unix timestamp

nonce

string

Block nonce (hex)

solution

string

Equihash solution (hex)

bits

string

Compact difficulty target

difficulty

number

Difficulty of this block

previousblockhash

string

Parent block hash

nextblockhash

string

Next block hash (empty at chain tip)

Use Cases

  • Header-First Sync: SPV clients download headers first to establish the canonical chain before fetching transactions

  • Reorg Detection: Compare header hashes across polls to detect chain reorganization

  • Lightweight Block Metadata: Get block timing, difficulty, and shielded-tree state without loading transactions

  • Chain History Reconstruction: Iterate headers backwards from a known hash to reconstruct chain history

Error Handling

Error Code
Message
Description

-5

Block not found

Requested hash doesn't exist

-32602

Invalid params

Hash is malformed

-32603

Internal error

Node failed to retrieve the header

Last updated

Was this helpful?