Skip to main content

Deposit SOL

Deposit SOL into the Privacy Cash privacy pool.

Example

import { PrivacyCash } from 'privacycash';

const client = new PrivacyCash({
    RPC_url: 'YOUR_SOLANA_MAINNET_RPC_URL',
    owner: 'YOUR_PRIVATE_KEY'
});

async function depositSol() {
    // Deposit 0.01 SOL
    const depositRes = await client.deposit({
        lamports: 0.01 * 1_000_000_000
    });
    console.log(depositRes);

    // Check balance after deposit
    const privateBalance = await client.getPrivateBalance();
    console.log('Balance after deposit:', privateBalance.lamports / 1_000_000_000, 'SOL');
}

depositSol();

How it Works

  1. You deposit SOL into a shielded pool
  2. A cryptographic commitment is generated
  3. The commitment is added to a Merkle tree on-chain
  4. You can later withdraw to any address without linking transactions

Important

  • Deposits are irreversible once confirmed
  • Historical UTXOs are cached locally for faster performance