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

bb_getBlockHash - Bitcoin Cash

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

This method returns the block hash at a given block height. It converts a height into the hash used by hash-based block lookups.

Parameters

Parameter
Type
Required
Description

height

integer

Yes

Block height on the main chain

Request

curl --location --request GET 'https://go.getblock.io/<ACCESS-TOKEN>/api/v2/block-index/684634'
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "bb_getBlockHash",
    "params": [
        684634
    ],
    "id": "getblock.io"
}'
example.js
const response = await fetch(
    'https://go.getblock.io/<ACCESS-TOKEN>/api/v2/block-index/684634'
);
console.log(await response.json());
example.py
import requests

response = requests.get('https://go.getblock.io/<ACCESS-TOKEN>/api/v2/block-index/684634')

print(response.json())

Response

{
    "blockHash": "0000000000000000023a561e1ea370153aac5d1504726d1a039032831c05fcfc"
}

Response Parameters

Field
Type
Description

blockHash

string

Hash of the block at the requested height

Use Cases

  • Height to Hash: Resolve a height into a hash for a block lookup

  • Sequential Access: Walk the chain by height when indexing blocks

  • Checkpoint Checks: Confirm a height maps to an expected block hash

  • Explorer Links: Build block detail links from height inputs

Error Handling

Error Code
Message
Description

400 / -32602

Bad request

The block height or hash is malformed

404 / -32603

Not found

No block matches the requested height or hash

500 / -32603

Internal error

The indexer failed to read the block

Was this helpful?