4.5 KiB
title, description
| title | description |
|---|---|
| useProof | Hook for return the account and storage values of the specified account including the Merkle-proof. |
useProof
Hook for return the account and storage values of the specified account including the Merkle-proof.
Import
import { useProof } from 'wagmi'
Usage
::: code-group
import { useProof } from 'wagmi'
function App() {
const result = useProof({
address: '0x4200000000000000000000000000000000000016',
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
Parameters
import { type UseProofParameters } from 'wagmi'
address
Address | undefined
The account address to get the proof for.
::: code-group
import { useProof } from 'wagmi'
function App() {
const result = useProof({
address: '0x4200000000000000000000000000000000000016', // [!code focus]
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
storageKeys
`0x${string}`[] | undefined
Array of storage-keys that should be proofed and included.
::: code-group
import { useProof } from 'wagmi'
function App() {
const result = useProof({
address: '0x4200000000000000000000000000000000000016',
storageKeys: [ // [!code focus:3]
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
blockNumber
bigint | undefined
Proof at a given block number.
::: code-group
import { useProof } from 'wagmi'
function App() {
const result = useProof({
address: '0x4200000000000000000000000000000000000016',
blockNumber: 42069n, // [!code focus]
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
blockTag
'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' | undefined
Proof at a given block tag.
::: code-group
import { useProof } from 'wagmi'
function App() {
const result = useProof({
address: '0x4200000000000000000000000000000000000016',
blockTag: 'latest', // [!code focus]
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
chainId
config['chains'][number]['id'] | undefined
The ID of chain to get the proof for.
::: code-group
import { useProof } from 'wagmi'
import { optimism } from 'wagmi/chains'
function App() {
const result = useProof({
chainId: optimism.id, // [!code focus]
address: '0x4200000000000000000000000000000000000016',
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
config
Config | undefined
Config to use instead of retrieving from the nearest WagmiProvider.
::: code-group
import { useProof } from 'wagmi'
import { config } from './config' // [!code focus]
function App() {
const result = useProof({
config, // [!code focus]
address: '0x4200000000000000000000000000000000000016',
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
scopeKey
string | undefined
Scopes the cache to a given context. Hooks that have identical context will share the same cache.
::: code-group
import { useProof } from 'wagmi'
import { config } from './config'
function App() {
const result = useProof({
scopeKey: 'foo' // [!code focus]
address: '0x4200000000000000000000000000000000000016',
storageKeys: [
'0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99',
],
})
}
<<< @/snippets/react/config.ts[config.ts] :::
Return Type
import { type UseProofReturnType } from 'wagmi'