getblockcount - Zcash
Example code for the getblockcount JSON-RPC method. Complete guide on how to use the getblockcount JSON-RPC method in GetBlock.io Web3 documentation.
This method returns the height of the current chain tip as an integer. The simplest chain-progress read — commonly polled by wallets, indexers, and monitoring dashboards.
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": "getblockcount",
"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: 'getblockcount',
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': 'getblockcount',
'params': [],
'id': 'getblock.io'
}
)
print(response.json())Response
{
"jsonrpc": "2.0",
"result": 3487829,
"id": "getblock.io"
}Response Parameters
result
integer
Height of the current chain tip
Use Cases
Chain Progress Polling: Detect new blocks by comparing successive polls
Confirmation Counting: Compute
getblockcount() - txBlockHeightto display confirmation counts in a wallet UISync Waiting: Wait for the tip to reach a specific target height during backfills or migrations
Error Handling
-32603
Internal error
Node has no blocks in state
Last updated
Was this helpful?