Skip to main content

Deposits

This guide covers depositing tokens from your wallet into your private balance using the Privacy Boost CLI.

CLI Command

privacy-boost deposit \
  --token 0x4200000000000000000000000000000000000006 \
  --amount 1.0 \
  --human
Output:
Deposit submitted!
Transaction: 0x1234...5678
Commitment: 0xabcd...ef01
Waiting for confirmation...
Deposit confirmed in block 12345678

Command Parameters

FlagRequiredDescription
--tokenYesERC-20 token contract address
--amountYesAmount to deposit
--humanNoInterpret amount as human-readable (default: wei)

Deposit Steps

When a deposit is submitted, the SDK executes these steps:
StepDescription
WrappingWrapping ETH to WETH (if depositing ETH)
ApprovingApproving token spending on the shield contract
ShieldingExecuting the deposit transaction
RegisteringRegistering the deposit with the indexer
ComplianceWaiting for compliance verification

Programmatic Usage (Rust)

use privacy_boost_cli::PrivacyBoostCLI;

let result = sdk.shield(
    "0x4200000000000000000000000000000000000006",
    "1000000000000000000", // 1 token in wei
)?;
println!("Deposit TX: {}", result.tx_hash);
println!("Commitment: {}", result.commitment);

DepositResult

pub struct DepositResult {
    pub tx_hash: String,
    pub commitment: String,
}

Depositing ETH

To deposit native ETH, use the zero address:
privacy-boost deposit \
  --token 0x0000000000000000000000000000000000000000 \
  --amount 1.0 \
  --human
The SDK automatically wraps ETH to WETH before depositing.

Working with Amounts

# Human-readable (with --human flag)
privacy-boost deposit --token $TOKEN --amount 1.5 --human

# Wei (default)
privacy-boost deposit --token $TOKEN --amount 1500000000000000000
Programmatic conversion:
let wei = sdk.parse_amount("1.5", 18)?;   // "1500000000000000000"
let eth = sdk.format_amount(&wei, 18)?;    // "1.5"

Error Handling

match sdk.shield(token_address, amount) {
    Ok(result) => println!("Deposit TX: {}", result.tx_hash),
    Err(CliError::InsufficientBalance) => println!("Not enough tokens in wallet"),
    Err(CliError::InvalidAmount) => println!("Invalid amount format"),
    Err(CliError::NotAuthenticated) => println!("Please login first"),
    Err(CliError::NetworkError { message }) => println!("Network error: {}", message),
    Err(e) => println!("Deposit failed: {:?}", e),
}

Best Practices

1. Use --human for Interactive Use

The --human flag makes amounts more readable and less error-prone.

2. Check Balance After Deposit

privacy-boost deposit --token $TOKEN --amount 1.0 --human
privacy-boost balance --token $TOKEN

Next Steps