getblockchaininfo

Bitcoin RPC

Overview

The getblockchaininfo is a Bitcoin RPC method that provides general information about the current state of the blockchain. This method is useful for obtaining an overview of the blockchain, including the best block hash, chain height, difficulty, and network protocol version. It can be used for various purposes, such as monitoring the blockchain, tracking network upgrades, and assessing the current mining difficulty.

Returns

The return object is a JSON object containing the following fields:

NameDescription
chainThe current network name (e.g., "main", "test", or "regtest").
blocksThe number of blocks in the local best block chain.
headersThe number of headers the local node has validated.
bestblockhashThe hash of the best (tip) block.
difficultyThe current mining difficulty.
mediantimeThe median block time of the last 11 blocks in UNIX timestamp format.
verificationprogressThe estimate of the verification progress of the local node as a percentage.
initialblockdownloadA boolean indicating whether the node is in the initial block download mode.
chainworkThe total work in the blockchain up to the best block.
size_on_diskThe estimated size of the block and undo files on disk.
prunedA boolean indicating whether the block chain is pruned.
pruneheightThe lowest-height complete block stored if the node is pruned (only present if pruned is true).
softforksAn array of objects, each containing information about a softfork.
bip9_softforksAn object containing the status of BIP9 softforks in the blockchain.
warningsAny network and blockchain warnings.

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/bitcoin-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "getblockchaininfo"
}'
// yarn add @tatumio/tatum

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

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

const result = await tatum.rpc.getBlockChainInfo()

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