getbestblockhash - Zcash

This method returns the hash of the current chain tip — the most recent block accepted into the canonical chain. Lightweight alternative to getblockchaininfo when only the tip hash is needed.

Parameters

This method takes no parameters.

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": "getbestblockhash",
    "params": [],
    "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: 'getbestblockhash',
    params: [],
    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': 'getbestblockhash',
        'params': [],
        '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": "getbestblockhash",
            "params": [],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;
    
    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "result": "000000000044b7b0276f3baa73a690467eaff42379eaeeb197a983c6f1408ce1",
    "id": "getblock.io"
}

Response Parameters

ParameterTypeDescription
resultstringHex-encoded 32-byte hash of the chain tip block

Use Cases

  • Reorg Detection: Poll the tip hash and compare to a stored previous value — a change without height advancement indicates a reorg
  • Cache Invalidation Key: Use the tip hash as a version key for cached chain-derived data
  • Lightweight Progress Signal: Cheap poll to detect chain advancement without loading full block metadata

Error Handling

Error CodeMessageDescription
-32603Internal errorNode has no blocks in state (fresh install) or failed to read the tip