Overview
This guide will help you get Privacy Cash running quickly. You’ll learn how to build the program, run tests, and execute your first private transaction.For production use, we recommend using the Privacy Cash SDK instead of building from source.
Prerequisites
Before you begin, ensure you have:Solana CLI
Version 2.1.18 or later
Rust
Version 1.79.0 or compatible
Anchor
Version 0.31.1
Node.js
Version 16 or later
See the installation guide for detailed setup instructions.
Build the program
1
Clone the repository
2
Navigate to the program directory
3
Build the Anchor program
4
Verify the build
Check that the compiled program exists:You should see the compiled program artifact.
Run tests
Privacy Cash includes comprehensive test suites for SOL and SPL token transactions.- SOL tests
- SPL tests
- Mint checked tests
- Unit tests
Test native SOL private transactions:This runs the test suite at
tests/sol_tests.ts which includes:- Double spend attack prevention
- Deposit and withdrawal with fees
- PDA recipient support
- Nullifier verification
The integration tests use the
localnet feature flag and spin up a local Solana validator automatically.Understanding a private transaction
Here’s a breakdown of how Privacy Cash transactions work using code from the test suite:1
Create UTXOs
For a deposit, create two output UTXOs (one with your amount, one empty):
2
Generate the zero-knowledge proof
Create the proof input and generate the proof:
3
Submit the transaction
Format the proof and submit to the program:
Deploy to devnet
Once you’ve tested locally, deploy to Solana devnet:1
Build with devnet feature
2
Prepare the program keypair
3
Deploy to devnet
Verifiable builds allow anyone to verify that the deployed program matches the source code. This is important for security and trust.
Next steps
Installation guide
Detailed setup instructions for all dependencies
Privacy Cash SDK
Integrate Privacy Cash into your application
Program source code
Explore the Rust implementation
Test suites
Review comprehensive test examples