> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.chainstack.com/feedback

```json
{
  "path": "/reference/arbitrum-getstorageat",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# eth_getStorageAt | Arbitrum

Arbitrum API method that returns the data stored at a specific storage slot within a smart contract. It can help developers to read a smart contract's internal state, like user data or balances, to inform decisions and build more advanced applications that interact with smart contracts on the blockchain.

<Note>
  When called against a block older than the latest \~128 blocks, this method is treated as an archive request (2 RUs instead of 1 RU). See [request units](/docs/request-units#archive-state-methods).
</Note>

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* `address` — the address of the smart contract to query
* `quantity` — the index of the storage position to retrieve the data from
* `quantity or tag` — the integer of a block encoded as hexadecimal or the string with:

  * `latest` — the most recent block in the blockchain and the current state of the blockchain at the most recent block
  * `earliest` — the earliest available or genesis block.
  * `pending` — the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block.

<Note>
  See the [default block parameter](https://eth.wiki/json-rpc/API#the-default-block-parameter).
</Note>

## Response

`data` — the data stored in the storage slot. Returned as a hexadecimal string.

## `eth_getStorageAt` code examples

The following example returns the storage value at slot `10` from the [Arbitrum Odyssey NFT collection](https://arbiscan.io/token/0xfAe39eC09730CA0F14262A636D2d7C5539353752#code) on the Arbitrum mainnet. In this case, this is the address owning the smart contract.

This method can retrieve the different storage values in time by querying different blocks in the past. Note that to query a state in the past, you need an [archive node](https://chainstack.com/evm-nodes-a-dive-into-the-full-vs-archive-mode).

<Note>
  curl needs a `HEX String` starting with `0x` to identify the block if you want to use a hex integer block number as a parameter.\
  For example, block number `14000000` will be `0xD59F80`.
</Note>

<CodeGroup>
  ```javascript web3.js theme={"system"}
  const Web3 = require("web3");
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const web3 = new Web3(NODE_URL);

  async function getstorage(address, slot, block) {
    const storage = await web3.eth.getStorageAt(address, slot, block)
    console.log(storage)
   }
   
   getstorage("0xfAe39eC09730CA0F14262A636D2d7C5539353752", 10, "latest" )
  ```

  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const getstorage = async (address, slot, block) => {
      const storage = await provider.send("eth_getStorageAt", [address, slot, block]);
      console.log(storage);
    };

  getstorage("0xfAe39eC09730CA0F14262A636D2d7C5539353752", "0xa", "latest" )
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL" 

  storage = web3.eth.get_storage_at("0xfAe39eC09730CA0F14262A636D2d7C5539353752",10, "latest")
  print(web3.to_hex(storage))
  ```
</CodeGroup>

## Use case

One use case for `eth_getStorageAt` is analyzing how the value stored at a specific storage slot of a smart contract changes over time. For example, a developer may want to track the change in a specific variable of a smart contract, such as the total supply of a token, and perform some analysis on it.

Here's an example implementation of this use case using web3.js.

The following program analyzes the [MIM](https://arbiscan.io/token/0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a#code) smart contract on the Arbitrum chain to track how the total supply changes over time.

The storage slot matches the position of the variable in the smart contract; the following code snippet shows the top of the MIM smart contract where the variables used in this program are declared.

```sol ERC20.sol theme={"system"}
contract AnyswapV5ERC20 is IAnyswapV3ERC20 {
    using SafeERC20 for IERC20;
    string public name;  // Slot 0
    string public symbol; // Slot 1
    uint8  public immutable override decimals; // Slot 2

    address public immutable underlying;

    bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
    bytes32 public constant TRANSFER_TYPEHASH = keccak256("Transfer(address owner,address to,uint256 value,uint256 nonce,uint256 deadline)");
    bytes32 public immutable DOMAIN_SEPARATOR;

    /// @dev Records amount of AnyswapV3ERC20 token owned by account.
    mapping (address => uint256) public override balanceOf;
    uint256 private _totalSupply; // Slot 8
  .
  .
  .
```

Here's an example implementation of this use case using web3.js:

```javascript index.js theme={"system"}
const Web3 = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);

// You need an archive node is going more than 127 blocks in the past.

async function getStorageValueOverTime() {
  // The address of the MIM smart contract
  const mimhAddress = '0xFEa7a6a0B346362BF88A9e4A88416B77a57D6c2A';

  // The index of the storage slots where the total supply and name data are stored
  const totalSupplySlot = 8;
  const nameSlot = 0;

  // The range of blocks to analyze
  const startBlock = 16000000;
  const endBlock = await web3.eth.getBlockNumber();

  for (let blockNumber = startBlock; blockNumber <= endBlock; blockNumber++) {

    // Retrieve the name and total supply from the smart contract storage at each block
    const [name, supply] = await Promise.all([
      web3.eth.getStorageAt(mimhAddress, nameSlot, blockNumber),
      web3.eth.getStorageAt(mimhAddress, totalSupplySlot, blockNumber)
    ]);

    // Decode the name and total supply from hexadecimal format to their original values
    const decodedName = web3.utils.hexToUtf8(name);
    const decodedSupply = web3.utils.toBN(supply);

    // Convert the total supply from Wei to Ether and round to 4 decimal places
    const convertedSupply = web3.utils.fromWei(decodedSupply, 'ether');
    const adjustedSupply = Number(convertedSupply).toFixed(4);

    // Output the block number, name, and total supply for each block
    console.log(`Block ${blockNumber}: Name = ${decodedName}, Total supply = ${adjustedSupply}`);
  }
}

async function main() {
  try {
    await getStorageValueOverTime();
  } catch (error) {
    console.error(error);
  }
}

main();
```

The bulk of the program is the `getStorageValueOverTime` function.

The `getStorageValueOverTime` function retrieves and outputs the name and total supply of the WETH smart contract at each block height between a specified start block and the current block height.

The function begins by declaring constants for the MIM contract address, the storage slot indices for the name and total supply data, the starting block height, and the current block height.

Next, the function enters a `for` loop that iterates over every block between the start block and the current block height. Within the loop, the function retrieves the name and total supply from the smart contract storage at the current block height using the `web3.eth.getStorageAt` method.

The `Promise.all` method is used to retrieve the name and total supply in parallel for improved efficiency. The `web3.utils.hexToUtf8` method is then used to convert the name from hexadecimal format to its original string value.

The `web3.utils.toBN` method is used to convert the total supply from hexadecimal format to a `BigNumber object`, which can be used for mathematical operations. The `web3.utils.fromWei` method is then used to convert the total supply from wei to ether.

Finally, the `Number` and `toFixed` methods are used to round the total supply to four decimal places and output the block number, name, and total supply for each block; note that this is for readability, and you should use the raw wei data to make calculations.

Overall, the `getStorageValueOverTime` function provides a way to monitor changes in the state of a smart contract over time, which can be useful for understanding the contract's behavior and performance.


## OpenAPI

````yaml /openapi/arbitrum_node_api/accounts_info/eth_getStorageAt.json POST /5b8d22690a57f293b3a1ed8758014e35
openapi: 3.0.0
info:
  title: Chainstack Node API
  version: 1.0.0
  description: This is an API for interacting with a Chainstack node.
servers:
  - url: https://nd-000-364-211.p2pify.com
security: []
paths:
  /5b8d22690a57f293b3a1ed8758014e35:
    post:
      tags:
        - upload
      summary: eth_getStorageAt
      operationId: getStorageAt
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                method:
                  type: string
                  default: eth_getStorageAt
                params:
                  type: array
                  items:
                    anyOf:
                      - type: string
                        title: Smart contract address
                        description: The address of the contract to query.
                      - type: string
                        title: Slot index
                        description: The index of the storage position to query.
                      - type: string
                        title: Block ID
                        description: The block number or tag to use as a reference.
                  default:
                    - '0x92c5dfaA4f5083914b1191a4618Ec35506C1CE16'
                    - '0x0'
                    - latest
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
      responses:
        '200':
          description: The value stored at the specified position.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````