getblockchaininfo
Returns the state of the blockchain, including the chain tip and sync progress. This method uses 80 credits from your daily balance.
Parameters
None
Returns
result: (object) - Blockchain state.
chain: (string) - Network name.mainfor mainnet andtestnet4for testnet.blocks: (integer) - Height of the most-work fully validated chain.headers: (integer) - Height of the most-work header chain the node has seen.bestblockhash: (string) - Hash of the chain tip.bits: (string) - Compact encoding of the proof-of-work target of the chain tip.target: (string) - Proof-of-work target of the chain tip, as a hex string.difficulty: (number) - Current proof-of-work difficulty.time: (integer) - Timestamp of the chain tip, in Unix epoch seconds.mediantime: (integer) - Median timestamp of the last 11 blocks, in Unix epoch seconds.verificationprogress: (number) - Estimated verification progress, from0to1.initialblockdownload: (boolean) -truewhile the node is still in initial block download.chainwork: (string) - Total work in the active chain, as a hex string.size_on_disk: (integer) - Estimated size of the block and undo files on disk, in bytes.pruned: (boolean) -truewhen the node prunes old blocks.warnings: (string) - Network and blockchain warnings. Empty when there are none.
Request
- curl
curl https://bitcoin-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "getblockchaininfo", "params": []}'
Response
- JSON
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"chain": "main",
"blocks": 971402,
"headers": 971402,
"bestblockhash": "00000000000000000000d5e7a6f1b2c39484a5b6c7d8e9f0a1b2c3d4e5f60718",
"bits": "17021ab4",
"target": "000000000000000000021ab40000000000000000000000000000000000000000",
"difficulty": 133759191625814.6,
"time": 1792671813,
"mediantime": 1792669377,
"verificationprogress": 0.9999987,
"initialblockdownload": false,
"chainwork": "0000000000000000000000000000000000000001128f3c63e0ce21b2a1d4c7b0",
"size_on_disk": 812937184301,
"pruned": false,
"warnings": ""
}
}