Skip to content
LogoLogo

Make Encrypted Zone Deposit

zone.encryptedDeposit

Deposits tokens into a zone from the parent Tempo chain, encrypting the recipient and memo for the zone sequencer.

Batches an approval and a ZonePortal encrypted deposit into a single transaction.

Usage

import {  } from './viem.config'
 
const {  } = await ..({
  : 100_000_000n,
  : '0x20c0000000000000000000000000000000000001',
  : 7,
})
 
.('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.encryptedDeposit action and wait for inclusion manually:

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

Prepared Usage

Encrypting the payload requires reading the sequencer's encryption key from the portal contract. Use prepare when one party chooses the private zone recipient and another party submits the parent-chain deposit transaction.

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

Prepared Recipient Usage

Use Actions.zone.encryptedDeposit.prepareRecipient when another contract or service handles token movement and only needs the zone portal encryption fields. The sender defaults to client.account.address. Set it explicitly when another account will call the zone portal.

import {  } from 'viem/tempo'
import {  } from './viem.config'
 
const { ,  } =
  await ...(, {
    : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
    : 7,
  })

The helper returns the encrypted payload and its key index together with the parent chain ID, portal address, sender, and zone ID.

Recipes

Pay an Employee Without Revealing the Recipient

Pass recipient and memo to run payroll into the zone: both fields are encrypted for the sequencer, so the public chain sees only the sender, token, and amount.

import {  } from 'viem/utils'
import {  } from './viem.config'
 
const {  } = await ..({
  : 4_250_000_000n,
  : .('payroll-2026-07', { : 32 }),
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : '0x20c0000000000000000000000000000000000001',
  : 7,
})

Run a Payroll Batch Concurrently

Pass nonceKey: 'expiring' to submit one encrypted deposit per employee from a single funding account, without serializing the batch on nonce order.

import {  } from './viem.config'
 
const  = [
  { : 4_250_000_000n, : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb' },
  { : 3_890_000_000n, : '0x8ba1f109551bD432803012645Ac136ddd64DBA72' },
] as 
 
const  = await .(
  .(() =>
    ..({
      ...,
      : 'expiring',
      : '0x20c0000000000000000000000000000000000001',
      : 7,
    }),
  ),
)
 
.(.(({  }) => .))
['success', 'success']

Return Value

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

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

Parameters

amount

  • Type: bigint

Amount of tokens to deposit.

memo

  • Type: Hex

Deposit memo. Encrypted alongside the recipient.

recipient

  • Type: Address
  • Default: account.address

Recipient address in the zone. Encrypted for the zone sequencer.

token

  • Type: Address

Token address to deposit.

zoneId

  • Type: number

Zone ID to deposit into.

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.