Skip to content
LogoLogo

earn.privateRedeem

Withdraws Earn 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 {  } from 'viem/tempo'
import {  as  } from './viem.config'
import {  as  } from './zones.config'
 
const  = await ...(, {
  : '0x0000000000000000000000000000000000000001',
  : ..,
  : ..,
  : 100_000_000n,
  : 50,
  : '0x0000000000000000000000000000000000000002',
  : 7,
})
 
const { ,  } = await ..()
{ transactionHash: '0x1234...abcd', ... }

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 {  } from 'viem/tempo'
import {  as  } from './viem.config'
import {  as  } from './zones.config'
 
const  = await ...(, {
  : 99_000_000n,
  : '0x0000000000000000000000000000000000000001',
  : ..,
  : ..,
  : 100_000_000n,
  : '0x0000000000000000000000000000000000000002',
  : 7,
})
 
const  = await ..()
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's private asset

Private asset returned to the Zone. If provided, it must match the gateway's immutable private asset. The callback cannot select another output token.

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

Zone gateway that processes the parent-chain callback.

portalAddress (optional)

  • Type: Address
  • Default: Derived from zoneId

Source Zone portal on the parent chain.

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

Earn 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%.

vault

  • Type: Address

Earn vault whose shares are redeemed.

withdrawalMemo (optional)

  • Type: Hex

Memo attached to the Zone withdrawal.

zoneId

  • Type: number

Source Zone receiving the returned assets.

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.

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.