Skip to content
LogoLogo

earn.privateRedeem

Withdraws vault shares from a private Zone, redeems them on Tempo, and returns the assets to an encrypted Zone recipient.

Usage

Prepare the encrypted callback with a parent Tempo client, then submit the withdrawal with the Zone client.

import { client as parentClient } from './viem.config'
import { client as zoneClient } from './zones.config'
 
const prepared = await parentClient.earn.privateRedeem.prepare({
  gateway: '0x0000000000000000000000000000000000000001',
  recipient: zoneClient.account.address,
  recoveryRecipient: parentClient.account.address,
  shareAmount: 100_000_000n,
  slippageBps: 50,
})
 
const { receipt, senderTag } = await zoneClient.earn.privateRedeemSync(prepared)
{ transactionHash: '0x1234...abcd', ... }
console.log('Sender tag:', senderTag)

The synchronous action confirms the Zone withdrawal. Use earn.waitForPrivateRedeem to wait for the parent-chain redemption. senderTag identifies the corresponding parent-chain WithdrawalProcessed event.

Asynchronous Usage

Use earn.privateRedeem to return the Zone transaction hash immediately.

import { client as parentClient } from './viem.config'
import { client as zoneClient } from './zones.config'
 
const prepared = await parentClient.earn.privateRedeem.prepare({
  assetAmountMin: 99_000_000n,
  gateway: '0x0000000000000000000000000000000000000001',
  recipient: zoneClient.account.address,
  recoveryRecipient: parentClient.account.address,
  shareAmount: 100_000_000n,
})
 
const hash = await zoneClient.earn.privateRedeem(prepared)
0x1234...abcd

Return Type

type ReturnType = {
  receipt: TransactionReceipt
  senderTag: Hash
}

The asynchronous action returns the transaction hash instead.

Prepare Return Type

type PreparedZoneRequest = {
  actionId: Hex
  amount: bigint
  callbackGas: bigint
  chainId: number
  data: Hex
  fallbackRecipient: Address
  fromBlock: bigint
  memo?: Hex
  to: Address
  token: Address
  zoneId: number
}

Pass the prepared value directly to earn.privateRedeem or earn.privateRedeemSync. The action checks that its parent and Zone chain IDs match the Zone client.

Prepare Parameters

actionId (optional)

  • Type: Hex
  • Default: A random bytes32 value

Correlation ID encoded in the gateway callback. Supply one when deterministic request preparation is needed.

assetAmount (optional)

  • Type: bigint

Quoted asset output. Provide it with slippageBps to avoid a live vault quote.

assetAmountMin (optional)

  • Type: bigint

Minimum assets returned to the Zone.

assetToken (optional)

  • Type: Address
  • Default: The gateway vault asset

Asset token returned to the Zone. A different token uses the gateway swap.

callbackGas (optional)

  • Type: bigint
  • Default: 10_000_000n

Gas reserved for the parent-chain gateway callback.

fallbackRecipient (optional)

  • Type: Address
  • Default: recoveryRecipient

Public recipient if the parent-chain gateway callback fails.

gateway

  • Type: Address

Gateway identifying the vault and Zone configuration.

recipient

  • Type: Address

Encrypted Zone recipient for the returned assets.

recoveryRecipient

  • Type: Address

Public Tempo recipient if the encrypted return deposit fails.

returnMemo (optional)

  • Type: Hex

Memo encrypted with the returned Zone deposit.

shareAmount

  • Type: bigint

Vault shares withdrawn from the Zone, in base units.

slippageBps (optional)

  • Type: number

Slippage tolerance below the provided or live quote, in basis points. For example, 50 means 0.5%.

withdrawalMemo (optional)

  • Type: Hex

Memo attached to the Zone withdrawal.

blockNumber (optional)

  • Type: bigint

Block number to read the state from.

blockOverrides (optional)

  • Type: BlockOverrides

Block overrides to apply to the state.

blockTag (optional)

  • Type: BlockTag

Block tag to read the state from.

stateOverride (optional)

  • Type: StateOverride

State override to apply.

Transaction Parameters

account (optional)

  • Type: Account | Address

Account that will be used to send the transaction.

feeToken (optional)

  • Type: Address | bigint

Fee token for the transaction.

Can be an unpaused USD-denominated TIP-20 token address or ID. Use client.fee.validateToken({ token }) to validate a token before submitting a transaction or setting it as a fee preference.

feePayer (optional)

  • Type: Account | true

Fee payer for the transaction.

Can be a Viem Account, or true if a Fee Payer Service will be used.

gas (optional)

  • Type: bigint

Gas limit for the transaction.

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' | bigint

Nonce key for the transaction. Use 'expiring' to use expiring nonces (TIP-1009), which enables concurrent transaction submission without nonce ordering.

validBefore (optional)

  • Type: number

Unix timestamp before which the transaction must be included.

validAfter (optional)

  • Type: number

Unix timestamp after which the transaction can be included.

throwOnReceiptRevert (optional)

  • Type: boolean
  • Default: true

Whether to throw an error if the transaction receipt indicates a revert. Only applicable to *Sync actions.