Overview
Theinitialize instruction sets up the Privacy Cash program for the first time. It creates the main merkle tree for SOL transactions, initializes the tree token account, and establishes global fee configuration.
This instruction can only be called once per program deployment and requires admin authorization on mainnet.
Function Signature
Accounts
The main merkle tree account for SOL transactions. PDA derived from
["merkle_tree"].- Mutable: Yes
- Initialized: Yes (created by this instruction)
Account that holds deposited SOL tokens. PDA derived from
["tree_token"].- Mutable: Yes
- Initialized: Yes (created by this instruction)
Global configuration account containing fee rates. PDA derived from
["global_config"].- Mutable: Yes
- Initialized: Yes (created by this instruction)
The authority that can initialize the program. Must match the admin pubkey on mainnet.
- Mutable: Yes (pays for account creation)
- Signer: Yes
The Solana system program.
Default Configuration
The instruction initializes the following default values:- Merkle Tree Height: 26 levels (67,108,864 maximum commitments)
- Root History Size: 100 historical roots
- Max Deposit Amount: 1,000 SOL (1,000,000,000,000 lamports)
- Deposit Fee Rate: 0% (free deposits)
- Withdrawal Fee Rate: 0.25% (25 basis points)
- Fee Error Margin: 5% (500 basis points)
Code Example
State Changes
MerkleTreeAccount
authority: Set to the signer’s public keynext_index: Initialized to 0root_index: Initialized to 0max_deposit_amount: Set to 1,000,000,000,000 lamportsheight: Set to 26root_history_size: Set to 100bump: PDA bump seedroot: Initialized to the empty tree root
TreeTokenAccount
authority: Set to the signer’s public keybump: PDA bump seed
GlobalConfig
authority: Set to the signer’s public keydeposit_fee_rate: Set to 0 (0% - free deposits)withdrawal_fee_rate: Set to 25 (0.25%)fee_error_margin: Set to 500 (5%)bump: PDA bump seed
Authorization
- Localnet
- Devnet
- Mainnet
No authorization required. Any account can initialize.
Errors
Thrown when the signer is not the authorized admin (mainnet/devnet only).
See Also
- initialize_spl_tree - Initialize a tree for SPL tokens
- update_global_config - Update fee configuration
- update_deposit_limit - Update deposit limits