getBlockHashes

Kadena RPC

Overview

The /chain/{chain}/hash endpoint retrieves a collection of block hashes from a specified Kadena chain in ascending order that satisfies various query parameters. This includes all block hashes within the chain database, even those of orphaned blocks. It is crucial for developers needing to track block creation or verify chain integrity.

Parameters

NameTypeRequiredDescription
apiVersionstringYesVersion of Kadena API "0.0"
nodeVersionenumYes"test-singleton" "development" "mainnet01" "testnet04"
chainstringYesThe specific chain ID from which to retrieve block hashes.
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.

Returns

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

FieldDescription
nextThe cursor for the next page of block hashes.
itemsAn array of block hashes, including hashes of orphaned blocks.
limitThe maximum number of block hashes returned in this response.

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/kadena-mainnet/{api_key}/chainweb/{apiVersion}/{nodeVersion}/chain/{chain}/hash?limit={limit}&next={next}&minheight={minheight}&maxheight={maxheight}' \
--header 'Content-Type: application/json'
// yarn add @tatumio/tatum

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

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

const blockHashes = await tatum.kadena.getBlockHashes({
  network: {
    apiVersion: "0.0",
    nodeVersion: "mainnet01",
    chain: "0", // Example chain ID
  },
  limit: 2,
  next: "inclusive:o1S4NNFhKWg8T1HEkmDvsTH9Ut9l3_qHRpp00yRKZIk",
  minheight: 1000000,
  maxheight: 1000001,
});

console.log(blockHashes);

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