getBlockBranches

Kadena RPC

Overview

The /chain/{chain}/block/branch endpoint retrieves a page of blocks from branches of the blockchain in descending order. This includes blocks that are ancestors of the 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 branches.
limitnumberNoThe maximum number of blocks to return.
nextstringNoA cursor for pagination to fetch subsequent blocks.
minheightnumberNoThe minimum block height to include in the results.
maxheightnumberNoThe maximum block height to include in the results.

Request Body

FieldTypeDescription
lowerarrayBlocks are not returned if they are predecessors of any block with a hash from this array.
upperarrayReturned blocks are predecessors of a block with a hash from this array. This includes blocks with hashes from this array.

Returns

A successful call to this endpoint returns a JSON object containing the following fields:

FieldDescription
nextThe cursor for the next page of block branches.
itemsAn array of JSON encoded blocks, detailing the branches in the blockchain.
limitThe maximum number of blocks 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}/block/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 blockBranches = await tatum.kadena.getBlockBranches({
  network: {
    apiVersion: "0.0",
    nodeVersion: "mainnet01",
    chain: "0", // Example chain ID
  },
  lower: ["RClyuyZAacwvPpmLXKbTwrIRXWeUSjiNhJVP2esH8KM"],
  upper: ["QxGCAz5AY1Y41nh1yWtgqhKhZ9pPiPRagFdIKNqBH74"],
  limit: 2,
});

console.log(blockBranches);

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