getStorageAt โ
Returns the value from a storage slot at a given address.
Usage โ
ts
import { toHex } from 'viem'
import { wagmiAbi } from './abi'
import { publicClient } from './client'
const data = await publicClient.getStorageAt({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
slot: toHex(0)
})
ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http()
})
Return Value โ
The value of the storage slot.
Parameters โ
address โ
- Type:
Address
The contract address.
ts
const data = await publicClient.getStorageAt({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
slot: toHex(0)
})
slot โ
- Type:
Hex
The storage position (as a hex encoded value).
ts
const data = await publicClient.getStorageAt({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
slot: toHex(0)
})