getbestblockhash - Zcash
Example code for the getbestblockhash JSON-RPC method. Complete guide on how to use the getbestblockhash JSON-RPC method in GetBlock.io Web3 documentation.
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
curl --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"
}'const 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);import 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())Response
{
"jsonrpc": "2.0",
"result": "000000000044b7b0276f3baa73a690467eaff42379eaeeb197a983c6f1408ce1",
"id": "getblock.io"
}Response Parameters
result
string
Hex-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
-32603
Internal error
Node has no blocks in state (fresh install) or failed to read the tip
Last updated
Was this helpful?