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

queryNetwork_blockHeight - Cardano

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

This method returns the height of the most recent block on the network the node is connected to. The height is the network's absolute chain length.

Parameters

This method does not require parameters.

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "queryNetwork/blockHeight",
    "id": "getblock.io"
}'
example.js
const response = await fetch(
    'https://go.getblock.io/<ACCESS-TOKEN>/',
    {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({"jsonrpc": "2.0", "method": "queryNetwork/blockHeight", "id": "getblock.io"})
    }
);
console.log(await response.json());
example.py
import requests

response = requests.post(
    'https://go.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={"jsonrpc": "2.0", "method": "queryNetwork/blockHeight", "id": "getblock.io"}
)

print(response.json())

Response

{
    "jsonrpc": "2.0",
    "method": "queryNetwork/blockHeight",
    "result": 13748117,
    "id": "getblock.io"
}

Response Parameters

Field
Type
Description

result

integer

Current network block height, or the string "origin" at genesis

Use Cases

  • Sync Checks: Compare against a local index to gauge sync progress

  • Confirmation Counts: Subtract a transaction's block height from the tip

  • Status Pages: Display the current chain height

  • Scheduling: Trigger jobs on block-height intervals

Error Handling

Error Code
Message
Description

-32602

Invalid params

A required field is missing or has the wrong type

-32000

Query unavailable

The query is not available in the current ledger era

-32603

Internal error

The node failed to answer the query

Last updated

Was this helpful?