Skip to content
LogoLogo

Deposit into Zone

zone.deposit

Deposits tokens into a zone from the parent Tempo chain.

Batches an approval and a ZonePortal 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.deposit action and wait for inclusion manually:

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

Recipes

Credit a Customer's Zone Balance

Pass recipient to credit the deposit to a customer's address in the zone, and memo to carry the internal ledger reference your reconciliation jobs match on.

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

Route Bounced Deposits to a Treasury Wallet

Pass bouncebackRecipient when depositing from an operational hot wallet, so a deposit the zone cannot credit refunds to your treasury instead of the sender.

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

Wait Until the Funds Are Spendable in the Zone

Combine the deposit receipt's block number with zone.waitForTempoBlock on the zone client to block until the zone has imported the deposit.

import {  } from './viem.config'
import {  as  } from './zones.config'
 
const {  } = await ..({
  : 100_000_000n,
  : '0x20c0000000000000000000000000000000000001',
  : 7,
})
 
const  = await ..({
  : .,
})
 
.('Imported Tempo block:', .)
Imported Tempo block: 123456n

Return Value

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

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

Parameters

amount

  • Type: bigint

Amount of tokens to deposit.

memo

  • Type: Hex

Deposit memo.

recipient

  • Type: Address
  • Default: account.address

Recipient address in the zone.

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.