# Deposit to a Zone

## Overview

Funds enter a zone by depositing them from Tempo Mainnet into the zone's contract. The deposit is
submitted on Mainnet against the L1 client, and the corresponding balance appears inside the zone once
the deposit is processed. An encrypted deposit additionally hides the recipient from the public chain.

[See the Zone Bridging specification](https://docs.tempo.xyz/protocol/zones/bridging)

:::warning
Tempo Zones are in early development and available on Tempo Testnet only. Expect breaking changes and
do not use them in production.
:::

## Recipes

These recipes assume you have [set up a Tempo client](/tempo) for Mainnet and
[connected to a zone](/tempo/guides/zones/connect).

### Deposit to a Zone

Deposit a TIP-20 token from your Mainnet balance into a zone with
[`zone.depositSync`](/tempo/actions/zone.deposit). The deposit runs on Mainnet, so it is sent with the
L1 client and targets the zone by `zoneId`.

:::code-group
```ts twoslash [example.ts]
import { parseUnits } from 'viem'
import { client } from './viem.config'

const { receipt } = await client.zone.depositSync({
  amount: parseUnits('100', 6),
  token: '0x20c0000000000000000000000000000000000001',
  zoneId: 7,
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

### Make an Encrypted Deposit

Hide the recipient of a deposit from the public chain with
[`zone.encryptedDepositSync`](/tempo/actions/zone.encryptedDeposit). Only the amount and sender remain
visible on Mainnet, while the recipient is decryptable only by the zone operator.

:::code-group
```ts twoslash [example.ts]
import { parseUnits } from 'viem'
import { client } from './viem.config'

const { receipt } = await client.zone.encryptedDepositSync({
  amount: parseUnits('100', 6),
  token: '0x20c0000000000000000000000000000000000001',
  zoneId: 7,
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

### Check Deposit Status

After depositing, confirm the funds have landed inside the zone with
[`zone.getDepositStatus`](/tempo/actions/zone.getDepositStatus), querying by the Mainnet block number
of your deposit. This call runs against the zone client.

:::code-group
```ts twoslash [example.ts]
import { client } from './zones.config'

const status = await client.zone.getDepositStatus({
  tempoBlockNumber: 123456n,
})
```

```ts twoslash [zones.config.ts] filename="zones.config.ts"
// [!include ~/snippets/tempo/zones.config.ts:setup]
```
:::

## Best Practices

### Deposit on Mainnet, Read on the Zone

Deposits are L1 actions sent with your Mainnet client, while status and balance reads are zone actions
sent with your zone client. Keep both clients configured so you can submit a deposit and then confirm
it landed.

### Prefer Encrypted Deposits for Privacy

If hiding the recipient matters, use `zone.encryptedDeposit` so the destination is not exposed on the
public chain. A plain deposit reveals the recipient on Mainnet.

### Prepare Private Details Before Broadcasting

If another wallet or service will broadcast the deposit, use
[`zone.encryptedDeposit.prepare`](/tempo/actions/zone.encryptedDeposit#prepared-usage) to encrypt the
private recipient and memo first. The broadcaster can pass the returned payload directly to
[`zone.encryptedDeposit`](/tempo/actions/zone.encryptedDeposit) without learning the private details.
Validate the public transaction details before broadcasting a prepared payload from another party.

### Track the Deposit Block Number

`zone.getDepositStatus` is keyed by the Mainnet block number of the deposit. Capture it from the
deposit receipt so you can reliably poll for processing.

## See More

<Cards>
  <Card icon="lucide:plug" title="Connect to a Zone" description="Authenticate a Viem client with a zone before reading state." to="/tempo/guides/zones/connect" />

  <Card icon="lucide:arrow-up-from-line" title="Withdraw from a Zone" description="Move stablecoins from a zone back to Tempo Mainnet." to="/tempo/guides/zones/withdraw" />

  <Card icon="lucide:square-function" title="zone.deposit" description="Deposit a TIP-20 token from Mainnet into a zone." to="/tempo/actions/zone.deposit" />

  <Card icon="lucide:book-open" title="Tempo Docs: Zone Bridging" description="How deposits and withdrawals move between Mainnet and zones." to="https://docs.tempo.xyz/protocol/zones/bridging" />
</Cards>
