Skip to content

zone.useRequestVerifiableWithdrawal ​

Hook for requesting a verifiable withdrawal from a zone to the parent Tempo chain.

Requires viem >=2.56.2

Zone actions and hooks require viem >=2.56.2.

Usage ​

ts
import { Hooks } from 'wagmi/tempo'
import { Zone } from 'viem/tempo'

const zoneChain = Zone.b
const requestWithdrawalSync = Hooks.zone.useRequestVerifiableWithdrawalSync()

requestWithdrawalSync.mutate({
  amount: 1_000_000n,
  chainId: zoneChain.id,
  revealTo:
    '0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  token: '0x20c0000000000000000000000000000000000001',
})

console.log('Transaction hash:', requestWithdrawalSync.data?.receipt.transactionHash)
// @log: Transaction hash: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

Asynchronous Usage ​

The example above uses a *Sync variant of the action, that will wait for the transaction to be included before returning.

If you are optimizing for performance, you should use the non-sync zone.requestVerifiableWithdrawal action and wait for inclusion manually:

ts
import { Hooks } from 'wagmi/tempo'
import { useWaitForTransactionReceipt } from 'wagmi'
import { Zone } from 'viem/tempo'

const zoneChain = Zone.b
const requestWithdrawal = Hooks.zone.useRequestVerifiableWithdrawal()
const { data: receipt } = useWaitForTransactionReceipt({
  hash: requestWithdrawal.data,
})

requestWithdrawal.mutate({
  amount: 1_000_000n,
  chainId: zoneChain.id,
  revealTo:
    '0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  token: '0x20c0000000000000000000000000000000000001',
})

console.log(receipt?.status)

Return Type ​

See TanStack Query mutation docs for more info hook return types.

data ​

See Wagmi Action zone.requestVerifiableWithdrawal Return Type

mutate/mutateAsync ​

See Wagmi Action zone.requestVerifiableWithdrawal Parameters

Parameters ​

config ​

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

mutation ​

See the TanStack Query mutation docs for more info hook parameters.

Action ​

Released under the MIT License.