getblockcount

BCH RPC

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, BitcoinCash, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<BitcoinCash>({network: Network.BITCOIN_CASH})

const result = await tatum.rpc.getBlockCount()

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

getblockcount is a method that returns the number of blocks in the local best blockchain. This method is useful for obtaining the current height of the blockchain, which can be used for various purposes, such as monitoring the blockchain, determining the number of confirmations for a transaction, or assessing the progress of the blockchain's growth.

Parameters

This method does not have any parameters.

Return Object

The returned object is an integer representing the number of blocks in the local best blockchain.

JSON Examples

Request example:

{% code overflow="wrap" lineNumbers="true" %}

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "getblockcount"
}

{% endcode %}

Response example:

{% code overflow="wrap" lineNumbers="true" %}

{
    "result": 787067,
    "error": null,
    "id": 1
}

{% endcode %}

\