getblockhash - Zcash

This method returns the block hash at a given height. Used by indexers iterating through historical blocks and by explorers resolving user-supplied height inputs to hashes.

Parameters

ParameterTypeRequiredDescription
heightintegerYesBlock height (0 or greater)

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getblockhash",
    "params": [
        3487790
    ],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'getblockhash',
    params: [
        3487790
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getblockhash',
        'params': [
            3487790
        ],
        'id': 'getblock.io'
    }
)

print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "getblockhash",
            "params": [
                3487790
            ],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;
    
    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "result": "00000000000f3c0bdf81aba0bf081c5c4882975cbc0a8ce35e70ddb5f265f1b1",
    "id": "getblock.io"
}

Response Parameters

ParameterTypeDescription
resultstringHex-encoded 32-byte block hash at the requested height

Use Cases

  • Height-to-Hash Resolution: Convert a user-supplied block height into a hash for subsequent detail queries
  • Historical Backfill: Iterate heights 0..tip to enumerate the full chain by hash
  • Explorer Search: Resolve numeric block searches to hashes for the detail view

Error Handling

Error CodeMessageDescription
-8Block height out of rangeRequested height exceeds the current chain tip
-32602Invalid paramsHeight parameter is malformed or negative
-32603Internal errorNode failed to look up the block