get_block_count - Monero

Example code for the get_block_count JSON-RPC method. Complete guide on how to use get_block_count JSON-RPC in GetBlock Web3 documentation.

This method returns the number of blocks in the longest chain known to the node. It is the cheapest call for determining the current chain tip and is the standard way to poll for new blocks on Monero.

Parameters

  • None

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "get_block_count",
    "params": {},
    "id": "getblock.io"
}'

Response Example

{
    "id": "getblock.io",
    "jsonrpc": "2.0",
    "result": {
        "count": 3194582,
        "status": "OK",
        "untrusted": false
    }
}

Response Parameters

Field
Type
Description

result.count

unsigned int

Number of blocks in the longest known chain

result.status

string

General RPC error code; OK means success

result.untrusted

boolean

true if the response came from bootstrap mode (untrusted), false if served locally

Use Cases

  • Polling for new blocks in indexers and explorers

  • Determining the current chain tip before making other calls

  • Health-checking the RPC endpoint

  • Mining-pool block-height tracking

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?