> ## Documentation Index
> Fetch the complete documentation index at: https://docs.privacyboost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Withdrawals

# Withdrawals

This guide covers withdrawing tokens from your private balance back to a wallet address using the Privacy Boost CLI.

## CLI Command

```bash theme={null}
privacy-boost unshield \
  --token 0x4200000000000000000000000000000000000006 \
  --amount 0.5 \
  --recipient 0x1234567890123456789012345678901234567890 \
  --human
```

Output:

```
Building proof... (this may take a moment)
Proof generated successfully
Withdraw submitted!
Transaction: 0x5678...9abc
Amount: 0.5 ETH
Recipient: 0x1234...7890
```

## Command Parameters

| Flag          | Required | Description                                       |
| ------------- | -------- | ------------------------------------------------- |
| `--token`     | Yes      | ERC-20 token contract address                     |
| `--amount`    | Yes      | Amount to withdraw                                |
| `--recipient` | Yes      | Recipient Ethereum address                        |
| `--human`     | No       | Interpret amount as human-readable (default: wei) |

## Programmatic Usage (Rust)

```rust theme={null}
let result = sdk.unshield(
    "0x4200000000000000000000000000000000000006",
    "500000000000000000", // 0.5 tokens in wei
    "0x1234567890123456789012345678901234567890",
)?;
println!("Withdraw TX: {}", result.tx_hash);
println!("Fee: {}", result.fee);
```

### UnshieldResult

```rust theme={null}
pub struct UnshieldResult {
    pub tx_hash: String,
    pub fee: String,
}
```

## Withdraw to Self

Withdraw to the connected wallet:

```bash theme={null}
privacy-boost unshield \
  --token $TOKEN \
  --amount 0.5 \
  --recipient $(privacy-boost status --json | jq -r .wallet_address) \
  --human
```

Programmatically:

```rust theme={null}
let wallet = sdk.get_wallet_address().unwrap();
let result = sdk.unshield(token_address, amount, &wallet)?;
```

## Error Handling

```rust theme={null}
match sdk.unshield(token_address, amount, recipient) {
    Ok(result) => println!("Withdraw TX: {}", result.tx_hash),
    Err(CliError::InsufficientBalance) => println!("Not enough shielded balance"),
    Err(CliError::InvalidAddress) => println!("Invalid recipient address"),
    Err(CliError::NotAuthenticated) => println!("Please login first"),
    Err(CliError::NetworkError { message }) => println!("Network error: {}", message),
    Err(e) => println!("Withdrawal failed: {:?}", e),
}
```

## Best Practices

### 1. Check Shielded Balance First

```bash theme={null}
privacy-boost balance --token $TOKEN
privacy-boost unshield --token $TOKEN --amount 0.5 --recipient $ADDR --human
```

### 2. Use `--human` for Readability

Avoid mistakes with large wei numbers by using human-readable amounts.

## Next Steps

* [Deposits Guide](./deposits)
* [Transfers Guide](./transfers)
* [Balances Guide](./balances)
* [Error Handling](./error-handling)
