Overview
Thedeposit operation moves tokens from a user’s public Associated Token Account (ATA) into an encrypted Encrypted Token Account (ETA). After a successful deposit, the balance is hidden on-chain.
Transfer from Public ATA
Tokens are moved from the user’s Associated Token Account (ATA) into the Shielded Pool - an on-chain SPL or Token-2022 custody account controlled by the Umbra program.
Fee Deduction
Protocol fees and any Token-2022 transfer fees are subtracted from the incoming amount. The net amount is what gets credited to the encrypted balance.
The user must be registered before depositing. An
EncryptedUserAccount PDA must exist for their wallet address.Usage
Parameters
The wallet address whose encrypted balance is credited. This is usually
client.signer.address (depositing to yourself), but you can deposit into any registered user’s account - the funds will be encrypted under their X25519 key.The SPL token mint address. Works with any standard SPL token and Token-2022 mints (see Token-2022 Support for transfer fee handling).
The gross amount to transfer, in the token’s native units (accounting for decimals). For example,
1_000_000n for 1 USDC (6 decimals). Protocol fees and Token-2022 transfer fees are subtracted from this amount before the ETA is credited.Additional compute unit price in microlamports. Increase this if transactions are timing out during periods of high network congestion.
A purpose flag stored alongside the deposit. Reserved for protocol use; leave at
0 unless instructed otherwise.32 bytes of arbitrary metadata stored with the deposit. Defaults to all zeros.
Return Value
Returns aPromise<TransactionSignature> - the signature of the confirmed deposit transaction.
Encryption Mode Selection
The SDK automatically selects the correct instruction variant based on the state of the destination user’s account:- New MXE-only balance - destination has no X25519 key registered; first deposit
- Existing MXE-only balance - destination has no X25519 key; balance already exists
- New Shared balance - destination has X25519 key registered; first deposit
- Existing Shared balance - destination has X25519 key; balance already exists
Protocol Fees
Fees are deducted from thetransferAmount before crediting the ETA. The amount credited is:
In most cases, direct deposits from your own ATA to your own ETA carry zero protocol fees - the
baseFee and commissionBps are both set to 0 for standard self-shielding. Fees may apply for deposits routed through relayers or for specific pool configurations.Example: Self-Deposit
Example: Deposit to Another User
You can shield tokens directly into another registered user’s encrypted balance:Error Handling
Deposit errors include astage field identifying where the failure occurred: