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
import { getDepositInstructionAsync } from "../private-channel-escrow-program/clients/typescript/src/generated";// allowedMint and instanceAta are auto-derived from mint and instanceconst 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_ADDRESSexplicitly, since it defaults to the standard SPL Token Program - The
allowed_mintPDA must exist (created byAllowMint); depositing an unlisted mint throwsInvalidAllowedMint - When
recipientisNone, the depositing user's channel balance is credited; when provided, the specified wallet's balance is credited instead - Both
payerandusermust sign the transaction - The
instance_atamust already exist (created byAllowMintfor this mint)
Is this page helpful?