Skip to content
LogoLogo

Request Verifiable Zone Withdrawal

zone.requestVerifiableWithdrawal

Requests a verifiable withdrawal from a zone to the parent Tempo chain. The zone sequencer encrypts the sender's identity for the provided revealTo public key.

Batches an approval and a ZoneOutbox withdrawal request into a single transaction.

Usage

import { ,  } from 'viem/utils'
import {  } from './zones.config'
 
// Generate a keypair for decrypting the sender identity later.
// Store the private key securely: the holder can reveal the sender.
const {  } = .()
const  = .(.())
 
const {  } = await ..({
  : 100_000_000n,
  ,
  : '0x20c0000000000000000000000000000000000001',
})
 
.('Transaction hash:', .)
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:

import { ,  } from 'viem/utils'
import {  } from './zones.config'
 
const {  } = .()
const  = .(.())
 
const  = await ..({
  : 100_000_000n,
  ,
  : '0x20c0000000000000000000000000000000000001',
})
const  = await ..({  }).

Recipes

Let an Auditor Verify Treasury Withdrawals

Pass an auditor's compressed public key as revealTo: withdrawals stay private onchain while only the auditor can decrypt and attest which zone account sent them.

import {  } from './zones.config'
 
// Compressed public key received from the auditor.
// The matching private key never leaves them.
const  = '0x0357e8a1e347b0c8e8c14290499e1281f84eae5d1cdd10cc5eb4d92aca17c5c1d4'
 
const {  } = await ..({
  : 100_000_000n,
  ,
  : '0x20c0000000000000000000000000000000000001',
})

Settle with a Counterparty Who Can Verify the Sender

Pass the counterparty's Mainnet address as to and their public key as revealTo, so they receive the funds and can decrypt proof of who paid.

import {  } from 'viem/utils'
import {  } from './zones.config'
 
const {  } = await ..({
  : 250_000_000n,
  : .('otc_trade_88', { : 32 }),
  : '0x02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc',
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : '0x20c0000000000000000000000000000000000001',
})

Return Value

type ReturnType = {
  /** Transaction receipt. */
  receipt: TransactionReceipt
}

The transaction receipt. The non-sync zone.requestVerifiableWithdrawal action returns the transaction hash.

Parameters

amount

  • Type: bigint

Amount of tokens to withdraw.

callbackGas

  • Type: bigint
  • Default: 0n

Gas limit reserved for the withdrawal callback on the parent chain.

data

  • Type: Hex

Callback data for the recipient on the parent chain.

fallbackRecipient

  • Type: Address
  • Default: to

Fallback address if the callback fails.

memo

  • Type: Hex

Withdrawal memo.

revealTo

  • Type: Hex

Compressed secp256k1 public key the sequencer encrypts the sender identity for.

to

  • Type: Address
  • Default: account.address

Recipient address on the parent Tempo chain.

token

  • Type: Address

Token address to withdraw.

For this action, the inherited gas parameter defaults to 10_000_000n. It limits the Zone transaction and is independent of callbackGas.

account (optional)

  • Type: Account | Address

Account that will be used to send the transaction.

feePayer (optional)

  • Type: Account | boolean

Fee payer for the transaction (TIP-1 gas sponsorship).

Pass true to defer the fee token to an external fee payer (e.g. a relay), or a local Account to co-sign the transaction as the fee payer.

feeToken (optional)

  • Type: Address | bigint

Fee token for the transaction.

Can be an unpaused USD-denominated TIP-20 token address or ID.

gas (optional)

  • Type: bigint

Gas limit for the transaction.

keyAuthorization (optional)

  • Type: KeyAuthorization

Signed key authorization to include with the transaction, authorizing an access key to act for the sending account.

maxFeePerGas (optional)

  • Type: bigint

Max fee per gas for the transaction.

maxPriorityFeePerGas (optional)

  • Type: bigint

Max priority fee per gas for the transaction.

nonce (optional)

  • Type: number

Nonce for the transaction.

nonceKey (optional)

  • Type: 'expiring' | 'random' | bigint

Nonce key for the transaction (TIP-1009 2D nonces).

Use 'expiring' to select an expiring nonce, which enables concurrent transaction submission without nonce ordering. Use 'random' to select a random key.

throwOnReceiptRevert (optional)

  • Type: boolean
  • Default: true

Whether a Sync action throws when the receipt reports a revert.

validAfter (optional)

  • Type: number

Unix timestamp after which the transaction can be included.

validBefore (optional)

  • Type: number

Unix timestamp before which the transaction must be included.