Skip to content
Cive

getStorageAt

Get the value from a storage slot at a given address.

Usage

import { toHex } from "cive";
import { publicClient } from "./client";
 
const hex = await publicClient.getStorageAt({
  address: "cfx:aakvz2e5nt82c9nvbbg84hzbrjy53nsdf26azny4p7",
  slot: toHex(2),
});

Return

Hex The value of the storage slot.

Parameters

address

  • Type: Address

The contract address.

import { toHex } from "cive";
const data = await publicClient.getStorageAt({
  address: "cfx:...", 
  slot: toHex(0),
});

slot

  • Type: Hex The storage position (as a hex encoded value).
import { toHex } from "cive";
const data = await publicClient.getStorageAt({
  address: "cfx:...",
  slot: toHex(0), 
});

epochTag (optional)

  • Type: latest_state| latest_confirmed| latest_checkpoint | earliest
  • Defaut: latest_state
import { toHex } from "cive";
const data = await publicClient.getStorageAt({
  address: "cfx:...",
  slot: toHex(0),
  epochTag: "latest_state", 
});

epochNumber (optional)

  • Type: bigint
import { toHex } from "cive";
const data = await publicClient.getStorageAt({
  address: "cfx:...",
  slot: toHex(0),
  epochNumber: 1n, 
});

JSON-RPC Method

cfx_getStorageAt