state_get_dictionary_item

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 dictionaryItemKey = '123245435346476'
const seedURef = 'uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007'
const stateRootHash = '0808080808080808080808080808080808080808080808080808080808080808'

const result = await tatum.rpc.stateGetDictionaryItem(
  {
    URef: {
      dictionary_item_key: dictionaryItemKey,
      seed_uref: seedURef,
    },
  },
  stateRootHash,
)

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": "state_get_dictionary_item",
  "params": [
    {
      "URef": {
        "dictionary_item_key": "123245435346476",
        "seed_uref": "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007"
      }
    },
    "0808080808080808080808080808080808080808080808080808080808080808"
  ]
}'

Overview

state_get_dictionary_item is an RPC method on the Casper blockchain that retrieves a specific dictionary item from the global state using a state root hash and a dictionary item key.

Parameters

The state_get_dictionary_item method accepts the following parameters:

  • dictionary_identifier: An object specifying the dictionary identifier, which includes:
    • URef: An object containing:
      • dictionary_item_key: The key of the dictionary item to retrieve. Example: "123245435346476"
      • seed_uref: The seed URef of the dictionary. Example: "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007"
  • state_root_hash: The state root hash to query. Example: "0808080808080808080808080808080808080808080808080808080808080808"

Return Object

The state_get_dictionary_item method returns an object with the following fields:

  • api_version: The API version. Example: "1.5.6"
  • stored_value: The stored value of the dictionary item.

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "api_version": "1.5.6",
    "stored_value": {
      "CLValue": {
        "bytes": "...",
        "cl_type": "...",
        "parsed": ...
      }
    }
  }
}

Notes

  • This method returns the value of a specific dictionary item from the global state.
  • Ensure to replace the state root hash, dictionary item key, and seed URef with the actual values you intend to query.

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