# storage_at

Returns one raw 32-byte storage word for a contract and BYTES32 slot in live, pinned, or retained execution state. Without a CLIENT, it builds a reusable READ and does not access state.

Canonical HTML: <https://determica.com/docs/functions/storage_at>

- Kind: scalar function
- Category: [Chain reads](/docs/category/chain-reads.md)
- Tags: RPC, Program Compiler, Simulate

Returns one raw 32-byte storage word for a contract and BYTES32 slot in live, pinned, or retained execution state. Without a CLIENT, it builds a reusable READ and does not access state.

## Overload 1: storage_at(CLIENT, ADDRESS, BYTES32)

```sql
storage_at(CLIENT, ADDRESS, BYTES32)
```

Reads the BYTES32 key in the CLIENT's current state context; only a live CLIENT necessarily resolves latest.

- Kind: scalar
- Execution context: Live RPC
- Behavior: Immediate Read
- Execution modes: Live Client, Pinned Client, Execution Client
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: External State
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: network_io

### Requirements

- client_state_context
- rpc

### Risks

- provider_limits
- chain_reorganization

### Inputs

- `client` (CLIENT; required; positional) — Readable EVM state represented by a live, pinned, or execution CLIENT.
- `address` (ADDRESS; required; positional) — Contract address whose storage should be read.
- `slot` (BYTES32; required; positional) — Exact 32-byte BYTES32 storage key. For mappings, pass the Solidity keccak-derived key as BYTES32.

### Returns

Raw 32-byte storage word

Returns the storage word as BYTES32. Historical reads may require an archive-capable RPC provider.

- `value` (BYTES32)

Raw 32-byte storage word. Returns the storage word as BYTES32. Historical reads may require an archive-capable RPC provider.

### Examples

_Named parameters · Needs RPC · RPC required_

```sql
-- Read storage slot 0
SELECT storage_at(
    $client,
    '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'::address, -- Ethereum mainnet WETH
    '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32
) AS value;
```

## Overload 2: storage_at(CLIENT, ADDRESS, BYTES32, BIGINT)

```sql
storage_at(CLIENT, ADDRESS, BYTES32, BIGINT)
```

Reads a BYTES32 storage key at an explicit block height; older heights may require archive hydration.

- Kind: scalar
- Execution context: Live RPC
- Behavior: Immediate Read
- Execution modes: Live Client, Pinned Client, Execution Client
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: External State
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: network_io

### Requirements

- client_state_context
- rpc

### Risks

- provider_limits
- chain_reorganization

### Inputs

- `client` (CLIENT; required; positional) — Readable EVM state represented by a live, pinned, or execution CLIENT.
- `address` (ADDRESS; required; positional) — Contract address whose storage should be read.
- `slot` (BYTES32; required; positional) — Exact 32-byte BYTES32 storage key. For mappings, pass the Solidity keccak-derived key as BYTES32.
- `block_number` (BIGINT; required; positional) — Optional historical block height.

### Returns

Raw 32-byte storage word

Returns the storage word as BYTES32. Historical reads may require an archive-capable RPC provider.

- `value` (BYTES32)

Raw 32-byte storage word. Returns the storage word as BYTES32. Historical reads may require an archive-capable RPC provider.

### Examples

_Named parameters · Needs RPC · RPC required_

```sql
-- Track slot changes across blocks
SELECT storage_at(
    $client,
    '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'::address, -- Ethereum mainnet WETH
    '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32,
    21000000 -- Ethereum mainnet block_number
) AS value;
```

## Overload 3: storage_at(ADDRESS, BYTES32)

```sql
storage_at(ADDRESS, BYTES32)
```

Records one address and BYTES32 key for a later storage lookup; construction does not access state.

- Kind: scalar
- Execution context: Live RPC
- Behavior: Read Builder
- Execution modes: Read Constructor
- Input shape: Scalar Arguments
- Planning contract: Deferred Execution
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Requirements

- rpc

### Inputs

- `address` (ADDRESS; required; positional) — Contract address whose storage should be observed.
- `slot` (BYTES32; required; positional) — Exact BYTES32 storage key, including a Solidity-derived mapping key when needed.

### Returns

Storage READ

Returns a READ whose successful EVM_VALUE contains the exact 32-byte word stored at the key.

- `read` (READ)

Storage READ. Returns a READ whose successful EVM_VALUE contains the exact 32-byte word stored at the key.

## Guidance

### Storage slot encoding

The SQL binder accepts BYTES32 for the storage key.

For Solidity mappings, compute keccak256(key . slot) using Solidity's layout and pass the resulting 32-byte key.

The same BYTES32 representation is used by simulation storage assumptions and READ builders.

- Use the block_number overload for reproducible historical evidence.
- Relation-sized attached pinned reads may share an adaptive hash-pinned proof or storage-call batch; every request keeps the durable blockHash and requireCanonical selector.
- Older slots may require an archive node.

### Evaluation

The READ accesses state only when an OBSERVATION consumes it during PROGRAM execution.

## Additional examples

```sql
SELECT storage_at('0x0000000000000000000000000000000000000001'::ADDRESS, '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32);
```

## Related functions

- [keccak256](/docs/functions/keccak256.md) — See Also
- [code_at](/docs/functions/code_at.md) — See Also
