Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Privacy-Cash/privacy-cash/llms.txt

Use this file to discover all available pages before exploring further.

Devnet is the ideal environment for testing Privacy Cash before deploying to mainnet. This guide covers building, deploying, and initializing the program on devnet.

Program Information

  • Network: Solana Devnet
  • Program ID: ATZj4jZ4FFzkvAcvk27DW9GRkgSbFnHo49fKKPQXU7VS
  • RPC Endpoint: Custom Helius endpoint (configured in scripts)

Build the Program

1

Navigate to Anchor Directory

cd anchor
2

Build with Devnet Features

Build the program with devnet-specific features:
anchor build -- --features devnet
Or build with verifiable flag:
anchor build --verifiable
3

Copy Program Keypair

Copy the program keypair to the deployment directory:
rm target/deploy/zkcash-keypair.json
cp zkcash-keypair.json target/deploy/zkcash-keypair.json

Deploy to Devnet

You have multiple deployment options:

Option 1: Using Anchor Deploy

anchor deploy --provider.cluster devnet

Option 2: Verifiable Deployment

For transparency and auditability:
anchor deploy --verifiable --provider.cluster devnet

Option 3: Using Solana CLI

Direct deployment with Solana CLI:
solana program deploy target/deploy/zkcash.so \
  --program-id zkcash-keypair.json \
  --upgrade-authority ./deploy-keypair.json
Ensure your deploy-keypair.json has sufficient SOL for deployment. You can request devnet SOL from the faucet:
solana airdrop 2 <your-address> --url devnet

Initialize the Program

After deployment, initialize the program state.

Initialize SOL Tree

Run the initialization script to set up the main SOL privacy pool:
cd ../scripts
npm install
npx ts-node initialize_devnet.ts
This script:
  • Derives required PDAs (Program Derived Addresses)
  • Creates the Merkle tree account for SOL deposits
  • Initializes the global configuration
  • Sets up the tree token account
Key Configuration:
  • Tree Height: 26 (supports ~67M leaves)
  • Root History Size: 100
  • Fee Recipient: DTqtRSGtGf414yvMPypCv2o1P8trwb9SJXibxLgAWYhw
  • Deposit Fee: 0% (free deposits)
  • Withdrawal Fee: 0.25% (25 basis points)

Initialize SPL Token Tree

To enable privacy for SPL tokens (e.g., USDC), initialize a separate tree:
npx ts-node initialize_spl_tree_devnet.ts
This script:
  • Creates a tree account specific to the SPL token mint
  • Sets maximum deposit limits
  • Configures token-specific parameters
Configuration:
  • USDC Mint (Devnet): 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
  • Max Deposit: 100,000 USDC
The global config must be initialized first (via initialize_devnet.ts) before initializing SPL token trees.

Verify Initialization

After initialization, verify the accounts on Solana Explorer:

Check SOL Tree Account

solana account <tree-account-address> --url devnet
Or view on Solana Explorer

Verify PDAs

The initialization scripts output the derived PDA addresses:
  • Tree Account: Stores the Merkle tree state
  • Tree Token Account: Holds deposited SOL/tokens
  • Global Config: Stores program-wide configuration

Common Issues

Program Already Initialized

If you see:
⚠️  Program already initialized on devnet!
The program state already exists. To reinitialize:
  1. Close existing accounts (if you have authority)
  2. Use a different program ID
  3. Continue with existing deployment

Insufficient Balance

# Check your balance
solana balance --url devnet

# Request airdrop if needed
solana airdrop 2 --url devnet

RPC Errors

The scripts use Helius RPC endpoints. If you encounter rate limits, you can:
  • Use your own RPC endpoint
  • Modify the connection URL in the scripts
  • Add delays between transactions

Testing Your Deployment

1

Run Unit Tests

cd ../anchor
cargo test
2

Run Integration Tests

Test SOL transfers:
npm run test:sol
Test SPL token transfers:
npm run test:spl
Test with mint-checked instruction:
npm run test:mint-checked

Next Steps

Mainnet Deployment

Ready for production? Deploy to mainnet

Verification

Verify your build matches the deployment

Build docs developers (and LLMs) love