Deposit

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

AccountWritableSignerDescription
payerFee payer for the transaction
userToken owner making the deposit
instanceEscrow instance PDA
mintSPL token mint
allowed_mintPDA verifying the mint is permitted on this instance
user_ataUser's associated token account (source)
instance_ataEscrow's associated token account (destination)
system_programSystem Program
token_programSPL Token Program
associated_token_programAssociated Token Program
event_authorityEvent authority PDA for EmitEvent CPI
private_channel_escrow_programEscrow Program (self-reference for CPI)

Parameters

ParameterTypeDescription
amountu64Amount of tokens to deposit, in the token's smallest unit
recipientOption<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 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)

Is this page helpful?

Spis treści

Edytuj stronę