chain_get_state_root_hash

Casper RPC

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, Casper, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Casper>({ network: Network.CASPER })

const blockHash = 'a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf' // Replace with actual block hash
const blockHeight = 3099175 // Replace with actual block height

const resultByHash = await tatum.rpc.chainGetStateRootHash({ hash: blockHash })
const resultByHeight = await tatum.rpc.chainGetStateRootHash({ height: blockHeight })

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

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/casper-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
    "jsonrpc":"2.0",
    "method":"chain_get_state_root_hash",
    "params":[
        {
            "Height": 3099175
        }
    ],
    "id":1
}'

Overview

chain_get_state_root_hash is an RPC method on the Casper blockchain that retrieves the state root hash for a given block hash or height. The state root hash is a key component for querying the global state of the blockchain.

Parameters

The chain_get_state_root_hash method accepts the following parameters:

  • block_identifier: An object specifying the block identifier, which can be either:
    • Hash: The hash of the block to retrieve. Example: "a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf"
    • Height: The height of the block to retrieve. Example: 3099175

Return Object

The chain_get_state_root_hash method returns an object with the following fields:

  • api_version: The API version. Example: "1.5.6"
  • state_root_hash: The state root hash. Example: "a306a9cf869e52fe9eacdc28aade94215112cc04b6737b3669c35568a47a7dc2"

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "api_version": "1.5.6",
    "state_root_hash": "a306a9cf869e52fe9eacdc28aade94215112cc04b6737b3669c35568a47a7dc2"
  }
}

Notes

  • This method returns the state root hash of a specific block from the network.
  • Ensure to replace the block hash or height with the actual block identifier you intend to query.

For more detailed information, refer to the official Casper documentation.