---
title: Deposit
description:
  Transfers SPL tokens from a user's wallet into the Private Channels escrow
---

Transfers SPL tokens from a user's associated token account into the escrow's
associated token account, crediting the depositing user's channel balance (or an
optional recipient's balance).

## Accounts

| Account                          | Writable | Signer | Description                                          |
| -------------------------------- | -------- | ------ | ---------------------------------------------------- |
| `payer`                          | ✓        | ✓      | Fee payer for the transaction                        |
| `user`                           |          | ✓      | Token owner making the deposit                       |
| `instance`                       |          |        | Escrow instance PDA                                  |
| `mint`                           |          |        | SPL token mint                                       |
| `allowed_mint`                   |          |        | PDA verifying the mint is permitted on this instance |
| `user_ata`                       | ✓        |        | User's associated token account (source)             |
| `instance_ata`                   | ✓        |        | Escrow's associated token account (destination)      |
| `system_program`                 |          |        | System Program                                       |
| `token_program`                  |          |        | SPL Token Program                                    |
| `associated_token_program`       |          |        | Associated Token Program                             |
| `event_authority`                |          |        | Event authority PDA for `EmitEvent` CPI              |
| `private_channel_escrow_program` |          |        | Escrow Program (self-reference for CPI)              |

## Parameters

| Parameter   | Type             | Description                                                                           |
| ----------- | ---------------- | ------------------------------------------------------------------------------------- |
| `amount`    | `u64`            | Amount of tokens to deposit, in the token's smallest unit                             |
| `recipient` | `Option<Pubkey>` | Optional on-chain recipient; if `None`, credits the depositing user's channel balance |

## Returns

Returns a `TransactionBuilder` that can be used to build and send the
transaction.

## Example

```typescript
import { getDepositInstructionAsync } from "../private-channel-escrow-program/clients/typescript/src/generated";

// allowedMint and instanceAta are auto-derived from mint and instance
const depositIx = await getDepositInstructionAsync({
  payer: payerSigner,
  user: userSigner,
  instance: instancePda,
  mint: mintAddress,
  userAta: userAtaAddress,
  amount: 1_000_000n,
  recipient: null
});
```

## Important Notes

- Program ID: `9tgHa1DcnaSSUtmMsst8ovKTe1Gfxzezn27KnH9xXYeU`
- For Token-2022 mints, pass `tokenProgram: TOKEN_2022_PROGRAM_ADDRESS`
  explicitly, since it defaults to the standard SPL Token Program
- The `allowed_mint` PDA must exist (created by `AllowMint`); depositing an
  unlisted mint throws `InvalidAllowedMint`
- When `recipient` is `None`, the depositing user's channel balance is credited;
  when provided, the specified wallet's balance is credited instead
- Both `payer` and `user` must sign the transaction
- The `instance_ata` must already exist (created by `AllowMint` for this mint)
