getBlockHashBranches

Kadena RPC

Overview

The /chain/{chain}/hash/branch endpoint retrieves a page of block hashes from branches of the blockchain in descending order. This method returns only blocks that are ancestors of some block in the set of upper bounds and are not ancestors of any block in the set of lower bounds.

Parameters

NameTypeRequiredDescription
apiVersionstringYesVersion of Kadena API "0.0"
nodeVersionenumYes"test-singleton" "development" "mainnet01" "testnet04"
chainstringYesThe specific chain ID for which to retrieve block hash branches.
limitnumberNoThe maximum number of block hashes to return.
nextstringNoA cursor for pagination to fetch subsequent block hashes.
minheightnumberNoThe minimum block height to include in the results.
maxheightnumberNoThe maximum block height to include in the results.

Request Body

FieldTypeDescription
lowerarrayAn array of block hashes. No block hashes are returned that are predecessors of any block with a hash from this array.
upperarrayAn array of block hashes. Returned block hashes are predecessors of a block with a hash from this array, including blocks with hashes from this array.

Returns

A successful call to the /chain/{chain}/hash/branch endpoint returns a JSON object containing the following fields:

FieldDescription
nextThe cursor for the next page of block hashes.
itemsAn array of block hashes, detailing the branches in the blockchain.
limitThe maximum number of block hashes returned in this response.

Request Example

curl --location --request POST 'https://api.tatum.io/v3/blockchain/node/kadena-mainnet/{api_key}/chainweb/{apiVersion}/{nodeVersion}/chain/{chain}/hash/branch?limit={limit}&next={next}&minheight={minheight}&maxheight={maxheight}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "lower": ["RClyuyZAacwvPpmLXKbTwrIRXWeUSjiNhJVP2esH8KM"],
    "upper": ["QxGCAz5AY1Y41nh1yWtgqhKhZ9pPiPRagFdIKNqBH74"],
}'
// yarn add @tatumio/tatum

import { TatumSDK, Kadena, Network } from "@tatumio/tatum";

const tatum = await TatumSDK.init<Kadena>({ network: Network.KADENA_MAINNET });

const blockHashBranches = await tatum.kadena.getBlockHashBranches({
  network: {
    apiVersion: "0.0",
    nodeVersion: "mainnet01",
    chain: "0", // Example chain ID
  },
  lower: ["RClyuyZAacwvPpmLXKbTwrIRXWeUSjiNhJVP2esH8KM"],
  upper: ["QxGCAz5AY1Y41nh1yWtgqhKhZ9pPiPRagFdIKNqBH74"],
});

console.log(blockHashBranches);

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