Instructions Reference
Detailed reference for all program instructions
Instructions Reference
Section titled “Instructions Reference”Detailed documentation for zklsol program instructions.
deposit
Section titled “deposit”Deposit tokens into the privacy pool with a cryptographic commitment.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | Depositor wallet |
signerTokenAccount | Yes | No | Depositor’s token account |
settings | No | No | Program settings PDA |
merkle | Yes | No | Merkle tree PDA |
merkleTokenAccount | Yes | No | Pool token account |
mint | No | No | Token mint |
systemProgram | No | No | System program |
tokenProgram | No | No | Token program |
rent | No | No | Rent sysvar |
Arguments
Section titled “Arguments”interface DepositArgs { commitment: number[]; // 32 bytes amount: BN; // Amount in base units}Example
Section titled “Example”await program.methods .deposit({ commitment: Array.from(commitment), amount: new BN(1000000), }) .accounts({ signer: wallet.publicKey, signerTokenAccount: userTokenAccount, settings, merkle, merkleTokenAccount, mint, systemProgram: SystemProgram.programId, tokenProgram: TOKEN_PROGRAM_ID, rent: SYSVAR_RENT_PUBKEY, }) .rpc();withdraw
Section titled “withdraw”Withdraw tokens using a ZK proof.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | Relayer/caller |
settings | No | No | Program settings |
merkle | Yes | No | Merkle tree |
merkleTokenAccount | Yes | No | Pool token account |
recipient | No | No | Recipient address |
recipientTokenAccount | Yes | No | Recipient token account |
mint | No | No | Token mint |
nullifierHash | Yes | No | Nullifier PDA (created) |
feeCollector | Yes | No | Fee collector |
feeCollectorTokenAccount | Yes | No | Fee token account |
systemProgram | No | No | System program |
tokenProgram | No | No | Token program |
Arguments
Section titled “Arguments”interface WithdrawArgs { nullifierHash: number[]; // 32 bytes proof: number[]; // 256 bytes root: number[]; // 32 bytes depositSize: BN;}withdraw_swap
Section titled “withdraw_swap”Withdraw and swap tokens in one operation.
Accounts
Section titled “Accounts”Similar to withdraw plus:
| Account | Description |
|---|---|
swapTokenAccount | Intermediate swap account |
outputMint | Output token mint |
outputTokenAccount | Output token destination |
Arguments
Section titled “Arguments”interface WithdrawSwapArgs { nullifierHash: number[]; proof: number[]; root: number[]; depositSize: BN; // Jupiter swap data passed via remaining accounts}revert
Section titled “revert”Recover funds from an unindexed deposit.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | Original depositor |
signerTokenAccount | Yes | No | Depositor’s token account |
settings | No | No | Program settings |
merkle | Yes | No | Merkle tree |
merkleTokenAccount | Yes | No | Pool token account |
mint | No | No | Token mint |
nullifierHash | No | No | Check not spent |
systemProgram | No | No | System program |
tokenProgram | No | No | Token program |
Arguments
Section titled “Arguments”interface RevertArgs { nullifier: number[]; // 32 bytes - original nullifier secret: number[]; // 32 bytes - original secret commitment: number[]; // 32 bytes - commitment hash}create_address_lookup_table
Section titled “create_address_lookup_table”Create an Address Lookup Table for the user.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | User wallet |
userAddressLookupTable | Yes | No | User LUT PDA |
addressLookupTable | Yes | No | Actual LUT account |
systemProgram | No | No | System program |
addressLookupTableProgram | No | No | ALT program |
rent | No | No | Rent sysvar |
Arguments
Section titled “Arguments”interface CreateAddressLookupTableArgs { recentSlot: BN; // Recent slot for derivation}extend_address_lookup_table
Section titled “extend_address_lookup_table”Add addresses to an existing LUT.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | LUT owner |
userAddressLookupTable | No | No | User LUT PDA |
addressLookupTable | Yes | No | Actual LUT |
addressLookupTableProgram | No | No | ALT program |
Remaining Accounts
Section titled “Remaining Accounts”Pass addresses to add as remaining accounts.
create_affiliate
Section titled “create_affiliate”Register as an affiliate.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | Affiliate wallet |
affiliate | Yes | No | Affiliate PDA |
settings | No | No | Program settings |
systemProgram | No | No | System program |
Arguments
Section titled “Arguments”interface CreateAffiliateArgs { affiliateCode: number[]; // Unique code feeShareBps: number; // Fee share in basis points}create_affiliate_token_account
Section titled “create_affiliate_token_account”Create token account for affiliate earnings.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | Affiliate |
affiliate | No | No | Affiliate PDA |
affiliateTokenAccount | Yes | No | Token account to create |
mint | No | No | Token mint |
tokenProgram | No | No | Token program |
associatedTokenProgram | No | No | ATA program |
systemProgram | No | No | System program |
withdraw_affiliate
Section titled “withdraw_affiliate”Withdraw accumulated affiliate earnings.
Accounts
Section titled “Accounts”| Account | Writable | Signer | Description |
|---|---|---|---|
signer | Yes | Yes | Affiliate |
affiliate | Yes | No | Affiliate PDA |
affiliateTokenAccount | Yes | No | Affiliate token account |
destinationTokenAccount | Yes | No | Where to send earnings |
tokenProgram | No | No | Token program |
Admin Instructions
Section titled “Admin Instructions”These instructions are restricted to program authority:
| Instruction | Purpose |
|---|---|
create_settings | Initialize program |
update_settings | Update configuration |
create_merkle | Create new Merkle tree |
create_merkle_node | Initialize tree node |
update_merkle_fees | Update fee rates |
create_fee_collector | Create fee collector |
withdraw_fee_collector | Withdraw fees |