A Rust CLI tool for wrapping any SPL token into confidential tokens using Solana's Token-2022 program with confidential transfer extensions.
This wrapper allows you to:
- Take any existing SPL token and wrap it into a confidential version
- Transfer the confidential tokens privately (amounts are encrypted)
- Unwrap confidential tokens back to the original SPL tokens
- Rust toolchain installed
- Solana CLI installed and configured
- A Solana wallet with SOL for transaction fees
- Access to Solana devnet/mainnet
- Clone the repository:
git clone https://github.com/deepakA18/Confidential-Transfer
cd confidential-transfer- Build the project:
cargo build --releaseThe CLI uses your default Solana wallet located at ~/.config/solana/id.json. Make sure you have:
- A configured Solana wallet
- Sufficient SOL for transaction fees
- Some SPL tokens to wrap (for testing)
Create a confidential wrapper for any SPL token:
cargo run --bin wrapper_example -- init --mint <SPL_TOKEN_MINT_ADDRESS>Example:
cargo run --bin wrapper_example -- init --mint ApxaHZoparjZFytE7Cxkp8meSybtmpXvgPjBzUpLdtkiConvert SPL tokens to confidential tokens:
cargo run --bin wrapper_example -- wrap --mint <SPL_TOKEN_MINT_ADDRESS> --amount <AMOUNT>Example:
cargo run --bin wrapper_example -- wrap --mint ApxaHZoparjZFytE7Cxkp8meSybtmpXvgPjBzUpLdtki --amount 10View details about the wrapper:
cargo run --bin wrapper_example -- info --mint <SPL_TOKEN_MINT_ADDRESS>Convert confidential tokens back to SPL tokens:
cargo run --bin wrapper_example -- unwrap --mint <SPL_TOKEN_MINT_ADDRESS> --amount <AMOUNT> --confidential-account <CONFIDENTIAL_ACCOUNT_ADDRESS>Example:
cargo run --bin wrapper_example -- unwrap --mint ApxaHZoparjZFytE7Cxkp8meSybtmpXvgPjBzUpLdtki --amount 5 --confidential-account 75ZupPZEyuU1vsZDkTjp1Lpfmh5ySZAodBfv5Viu3uCUCheck account balance:
cargo run --bin wrapper_example -- balance --account <ACCOUNT_ADDRESS>Fund an account with SOL:
cargo run --bin wrapper_example -- fund --account <ACCOUNT_ADDRESS> --amount 1.0- User deposits original SPL tokens into a secure vault
- Equivalent confidential wrapper tokens are minted using Token-2022
- Tokens are moved to confidential balance using encryption
- User receives confidential tokens with encrypted amounts
- Confidential tokens are withdrawn from encrypted balance to public balance
- Wrapper tokens are burned
- Original SPL tokens are released from vault back to user
- Deterministic wrapper mints: Same wrapper mint generated for same original token
- Secure vault system: Original tokens locked until unwrapping
- Zero-knowledge proofs: Transactions proven valid without revealing amounts
- ElGamal + AES encryption: Private keys unique to each user
--rpc-url: Solana RPC endpoint (default: https://api.devnet.solana.com)--keypair-path: Path to keypair file (default: ~/.config/solana/id.json)--verbose: Enable debug logging
Complete workflow with USDC on devnet:
# 1. Initialize wrapper for USDC
cargo run --bin wrapper_example -- init --mint 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
# 2. Wrap 100 USDC tokens
cargo run --bin wrapper_example -- wrap --mint 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU --amount 100
# 3. Check wrapper status
cargo run --bin wrapper_example -- info --mint 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
# 4. Unwrap 50 USDC tokens back
cargo run --bin wrapper_example -- unwrap --mint 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU --amount 50 --confidential-account <YOUR_CONFIDENTIAL_ACCOUNT>src/
├── lib.rs # Main library exports and types
├── wrapper.rs # Core confidential wrapper implementation
├── utils.rs # Utility functions
├── main.rs # Original confidential transfer demo
└── bin/
└── wrapper_example.rs # CLI application
Key dependencies include:
solana-sdk: Solana blockchain interactionspl-token: SPL token operationsspl-token-2022: Token-2022 program with extensionsspl-token-client: High-level token client- Confidential transfer proof libraries
clap: Command line argument parsing
"Invalid Mint" Error: Ensure the wrapper is initialized before wrapping tokens.
"Insufficient Balance" Error: Make sure you have enough of the original SPL tokens and SOL for transaction fees.
"Account Not Found" Error: The specified mint address or account doesn't exist.
Transaction Failures: Check your SOL balance and network connectivity.