Skip to main content

Private Transfers

This guide covers sending tokens privately between privacy addresses using the Privacy Boost CLI.

CLI Command

privacy-boost send \
  --token 0x4200000000000000000000000000000000000006 \
  --amount 0.1 \
  --recipient 0x04...194-char-privacy-address \
  --human
Output:
Building proof... (this may take a moment)
Proof generated successfully
Transfer submitted!
Transaction: 0x9abc...def0
Amount: 0.1 ETH
Recipient: 0x04ab...ef01 (privacy address)

Command Parameters

FlagRequiredDescription
--tokenYesToken contract address
--amountYesAmount to send
--recipientYesRecipient’s 194-character privacy address
--humanNoInterpret amount as human-readable (default: wei)

Programmatic Usage (Rust)

let result = sdk.send(
    "0x4200000000000000000000000000000000000006",
    "100000000000000000", // 0.1 tokens in wei
    "0x04...recipient-privacy-address",
)?;
println!("Transfer TX: {}", result.tx_hash);
println!("Fee: {}", result.fee);

TransferResult

pub struct TransferResult {
    pub tx_hash: String,
    pub fee: String,
}

Privacy Address Validation

Validate the recipient address before sending:
if !sdk.is_valid_privacy_address(recipient) {
    println!("Invalid privacy address");
    return;
}

let result = sdk.send(token_address, amount, recipient)?;

Address Lookup

Look up a user’s privacy address:
let identity = sdk.resolve_identity("0x...wallet-address")?;
println!("Privacy address: {}", identity.privacy_address);

sdk.send(token_address, amount, &identity.privacy_address)?;

Error Handling

match sdk.send(token_address, amount, recipient_privacy_address) {
    Ok(result) => println!("Transfer TX: {}", result.tx_hash),
    Err(CliError::InsufficientBalance) => println!("Not enough shielded balance"),
    Err(CliError::InvalidAddress) => println!("Invalid privacy address"),
    Err(CliError::NotAuthenticated) => println!("Please login first"),
    Err(CliError::NetworkError { message }) => println!("Network error: {}", message),
    Err(e) => println!("Transfer failed: {:?}", e),
}

Best Practices

1. Validate Addresses Before Sending

Always validate the privacy address before attempting a transfer.

2. Check Balance After Transfer

privacy-boost send --token $TOKEN --amount 0.1 --recipient $PRIVACY_ADDR --human
privacy-boost balance --token $TOKEN

Next Steps