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

getblockcount - Zcash

Example code for the getblockcount JSON-RPC method. Сomplete 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://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getblockcount",
    "params": [],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

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

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://go.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",
    "id": "getblock.io",
    "result": 3420501
}

Response Parameters

Parameter
Type
Description

result

integer

Height of the current chain tip

Use Cases

  • Chain Progress Polling: Detect new blocks by comparing successive polls

  • Confirmation Counting: Compute getblockcount() - txBlockHeight to display confirmation counts in a wallet UI

  • Sync Waiting: Wait for the tip to reach a specific target height during backfills or migrations

Error Handling

Error Code
Message
Description

-32603

Internal error

Node has no blocks in state

Last updated

Was this helpful?