chain_get_era_by_block

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 = 3229836 // Replace with actual block height

const resultByHash = await tatum.rpc.chainGetEraByBlock({ hash: blockHash })
const resultByHeight = await tatum.rpc.chainGetEraByBlock({ 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 '{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "chain_get_era_info_by_switch_block",
    "params": [
        {
            "Hash": "a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf"
        }
    ]
}'

Overview

chain_get_era_info_by_switch_block is an RPC method on the Casper blockchain that retrieves the era information by a given switch block hash.

Parameters

The chain_get_era_info_by_switch_block method accepts the following parameters:

  • hash: The hash of the block to retrieve.
    Or
  • height Identify and retrieve the Block with its height.

Return Object

The chain_get_era_info_by_switch_block method returns an object with the following fields:

  • api_version: The API version. Example: "1.5.6"
  • era_summary: An object containing the era summary information.

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "api_version": "1.5.6",
    "era_summary": {
      "era_id": 123,
      "state_root_hash": "a4b607420ae737f9cd474af73c9f5e908f61edd2e57d48371d15835127b46aaf",
      "stored_value": {
        "EraInfo": {
          ...
        }
      }
    }
  }
}

Notes

  • This method returns the era information for a given switch block hash.
  • Ensure to replace the block hash with the actual value you intend to query.

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