Deposit SOL
Deposit SOL into the Privacy Cash privacy pool.
const result = await client.deposit({
lamports: number
})
Parameters
| Parameter | Type | Required | Description |
|---|
lamports | number | Yes | Amount in lamports (1 SOL = 1,000,000,000 lamports) |
Returns
{
tx: string // Transaction signature
}
Example
import { PrivacyCash } from 'privacycash'
const client = new PrivacyCash({
RPC_url: process.env.SOLANA_RPC_URL!,
owner: process.env.PRIVATE_KEY!
})
// Deposit 0.1 SOL
const result = await client.deposit({
lamports: 0.1 * 1_000_000_000 // 100,000,000 lamports
})
console.log('Transaction:', result.tx)
console.log('Explorer:', `https://explorer.solana.com/tx/${result.tx}`)
Deposit Limits
The protocol enforces deposit limits to prevent abuse. Check the current limit before depositing large amounts.
If you exceed the deposit limit, the transaction will fail with Don't deposit more than X SOL.
Fees
| Fee Type | Amount |
|---|
| Protocol fee | Free (0) |
| Network fee | ~0.002 SOL (Solana transaction fee) |
How Deposits Work
Transaction Created
The SDK creates a deposit transaction with your signed proof
Relayer Screening
Your wallet address is screened through CipherOwl for malicious activity
On-Chain Submission
The relayer submits the transaction to Solana
UTXO Created
An encrypted UTXO is created and stored on-chain, only decryptable by you
Zero-Knowledge Proof
When you deposit, the SDK generates a ZK proof that:
- Proves you own the funds being deposited
- Creates an encrypted commitment that only you can decrypt
- Ensures the relayer cannot modify any parameters
// The SDK handles all ZK proof generation automatically
const result = await client.deposit({
lamports: 50_000_000 // 0.05 SOL
})
// Behind the scenes:
// 1. ZK proof generated
// 2. Transaction signed
// 3. Sent to relayer
// 4. Confirmed on-chain
Consolidation
If you already have a private balance, new deposits are automatically consolidated with existing UTXOs:
// First deposit: 0.1 SOL
await client.deposit({ lamports: 100_000_000 })
// Check balance
let balance = await client.getPrivateBalance()
console.log(balance.lamports) // 100,000,000
// Second deposit: 0.05 SOL (consolidates with first)
await client.deposit({ lamports: 50_000_000 })
// Balance is combined
balance = await client.getPrivateBalance()
console.log(balance.lamports) // 150,000,000
Consolidation happens automatically. You don’t need to manage UTXOs manually.
Best Practices
Round Amounts
Deposit round, integer amounts (e.g., 1 SOL, 0.5 SOL) to avoid amount-based correlation
Common Amounts
Use common deposit amounts that others also use to increase your anonymity set
Example: Privacy-Optimized Deposit
// Good: Round amount
await client.deposit({ lamports: 1_000_000_000 }) // 1 SOL
// Avoid: Unique amount that's easy to trace
await client.deposit({ lamports: 1_234_567_890 }) // 1.23456789 SOL
Error Handling
try {
const result = await client.deposit({
lamports: 100_000_000
})
console.log('Deposit successful:', result.tx)
} catch (error) {
if (error.message.includes('Insufficient balance')) {
console.error('Not enough SOL in wallet')
} else if (error.message.includes("Don't deposit more than")) {
console.error('Deposit exceeds protocol limit')
} else {
console.error('Deposit failed:', error.message)
}
}
Common Errors
| Error | Solution |
|---|
Insufficient balance | Add more SOL to your wallet |
Don't deposit more than X SOL | Reduce deposit amount |
response not ok | Check RPC connection, try again |