> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Get Storage Value \[address.getStorageAt]

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

## Usage

This example returns the value from a storage slot at a given address.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const value = await client.address.getStorageAt({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0',
})
// @log: '0x0000000000000000000000000000000000000000000000000000000000000001'
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())
```
:::

### Standalone Action

Call `Actions.address.getStorageAt` directly by passing the Client as the first argument.

:::code-group
```ts twoslash [example.ts]
import { Actions } from 'viem'
import { client } from './viem.config'

const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0',
})
// @log: '0x0000000000000000000000000000000000000000000000000000000000000001'
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
})
```
:::

## Recipes

### Read Historical Contract Storage

Use `blockNumber` to read a slot from historical state. Determine the slot from the contract's storage layout before interpreting the returned bytes.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const value = await client.address.getStorageAt({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  blockNumber: 19_000_000n, // [!code focus]
  slot: '0x0',
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())
```
:::

## Return Value

`Hex | undefined`

The value stored at the slot.

## Parameters

### address

* **Type:** `Address`

The address of the contract to read storage from.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', // [!code focus]
  slot: '0x0',
})
```

### blockHash

* **Type:** `Hex`

The storage value at a given block hash (EIP-1898).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0',
  blockHash: '0x89644bbd5c8d682a2e9611170e6c1f02573d866d286f006cbf517eec7254ec2d', // [!code focus]
})
```

### blockNumber

* **Type:** `bigint`

The storage value at a given block number.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0',
  blockNumber: 42069n, // [!code focus]
})
```

### blockTag

* **Type:** `'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'`
* **Default:** `'latest'`

The storage value at a given block tag.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0',
  blockTag: 'safe', // [!code focus]
})
```

### requireCanonical

* **Type:** `boolean`

Whether to error if the `blockHash` is not in the canonical chain. Can only be provided alongside `blockHash`.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0',
  blockHash: '0x89644bbd5c8d682a2e9611170e6c1f02573d866d286f006cbf517eec7254ec2d',
  requireCanonical: true, // [!code focus]
})
```

### slot

* **Type:** `Hex`

The storage slot (position) to read.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const value = await Actions.address.getStorageAt(client, {
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  slot: '0x0', // [!code focus]
})
```

## Errors

| Error | Description |
| --- | --- |
| `BlockParameter.RequireCanonicalError` | `requireCanonical` was provided without a `blockHash`. |
