getStorageAt
Action for getting Starknet contract storage value at a specific key.
Import
import { getStorageAt } from "starkweb/core";
Usage
index.ts
import { getStorageAt } from "starkweb/core";
import { config } from "./config";
const value = await getStorageAt(config, {
contractAddress: "0x123...",
key: "0x456...",
});
Parameters
import { type GetStorageAtParameters } from "starkweb/core";
contractAddress
Hex
The address of the contract to read storage from.
key
Hex
The storage key to read.
index.ts
import { getStorageAt } from "starkweb/core";
import { config } from "./config";
const value = await getStorageAt(config, {
contractAddress: "0x123...",
key: "0x456...",
});
chainId (optional)
Hex | undefined
The chain ID to read from. If not provided, uses the current chain.
index.ts
import { getStorageAt } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
const value = await getStorageAt(config, {
contractAddress: "0x123...",
key: "0x456...",
chainId: mainnet.chain_id,
});
Return Type
import { type GetStorageAtReturnType } from "starkweb/core";
Hex
The value stored at the given key.
Example
example.ts
import { getStorageAt } from "starkweb/core";
import { mainnet, testnet } from "starkweb/chains";
import { config } from "./config";
// Read storage on current chain
const value = await getStorageAt(config, {
contractAddress: "0x123...",
key: "0x456...",
});
console.log("Storage value:", value);
// Read storage on specific chain
const mainnetValue = await getStorageAt(config, {
contractAddress: "0x123...",
key: "0x456...",
chainId: mainnet.chain_id,
});
Error
import { type GetStorageAtErrorType } from "starkweb/core";
TanStack Query
import {
type GetStorageAtData,
type GetStorageAtQueryFnData,
type GetStorageAtQueryKey,
getStorageAtQueryKey,
getStorageAtQueryOptions,
} from "starkweb/query";