Skip to main content
Tempo API method that returns the value from a storage position at a given address. This is useful for reading raw contract storage slots.

Parameters

  • address — the address of the contract
  • storagePosition — the position in storage (hex)
  • blockParameter — the block number (hex) or tag (latest, earliest, pending)

Response

  • result — the value at the storage position encoded as hexadecimal

eth_getStorageAt code examples

const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

// pathUSD token address
const PATHUSD = "0x20c0000000000000000000000000000000000000";

const getStorage = async () => {
    // Slot 0 typically contains the total supply in ERC20 contracts
    const value = await provider.getStorage(PATHUSD, 0);
    console.log(`Storage slot 0: ${value}`);

    // Read a specific slot
    const slot5 = await provider.send("eth_getStorageAt", [
      PATHUSD,
      "0x5",
      "latest"
    ]);
    console.log(`Storage slot 5: ${slot5}`);
  };

getStorage();