> ## 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.

# Transactions

# Transaction History

This guide covers querying and filtering transaction history using the Privacy Boost CLI.

## CLI Command

```bash theme={null}
# All transactions
privacy-boost history

# Filter by type (shield=deposit, unshield=withdraw, transact=transfer)
privacy-boost history --tx-type shield
privacy-boost history --tx-type unshield
privacy-boost history --tx-type transact

# Filter by token
privacy-boost history --token 0x4200000000000000000000000000000000000006

# Limit results
privacy-boost history --limit 10
```

Output:

```
Type       Token        Amount     Direction  Date
deposit    WETH         1.0 ETH    in         2024-01-15 10:30:00
transfer   WETH         0.5 ETH    out        2024-01-15 11:00:00
withdraw   WETH         0.25 ETH   out        2024-01-15 12:00:00
```

## Programmatic Usage (Rust)

### Basic Usage

```rust theme={null}
let transactions = sdk.get_transaction_history(None, None, None)?;
for tx in &transactions {
    println!("{}: {} - {}", tx.tx_type, tx.amount, tx.tx_hash);
}
```

### Filtering

```rust theme={null}
// Only deposits
let deposits = sdk.get_transaction_history(Some("deposit"), None, None)?;

// Only withdrawals
let withdrawals = sdk.get_transaction_history(Some("withdraw"), None, None)?;

// Last 10 transactions for a specific token
let recent = sdk.get_transaction_history(
    None,
    Some("0x4200000000000000000000000000000000000006"),
    Some(10),
)?;
```

### Transaction Type

```rust theme={null}
pub struct Transaction {
    pub tx_hash: String,
    pub tx_type: String,         // "deposit", "withdraw", or "transfer"
    pub token_address: String,
    pub amount: String,          // Amount in wei
    pub direction: String,       // "in" or "out"
    pub sender_pub_key: String,
    pub receiver_pub_keys: Vec<String>,
    pub created_at: u64,         // Unix timestamp
}
```

## Filter Parameters

| Parameter       | Type           | Description                                             |
| --------------- | -------------- | ------------------------------------------------------- |
| `tx_type`       | `Option<&str>` | Filter by type: `"deposit"`, `"withdraw"`, `"transfer"` |
| `token_address` | `Option<&str>` | Filter by token contract address                        |
| `limit`         | `Option<u32>`  | Maximum number of results                               |

## Error Handling

```rust theme={null}
match sdk.get_transaction_history(None, None, None) {
    Ok(transactions) => {
        for tx in &transactions {
            println!("{}: {}", tx.tx_type, tx.amount);
        }
    }
    Err(CliError::NotAuthenticated) => println!("Please login first"),
    Err(CliError::NetworkError { message }) => println!("Network error: {}", message),
    Err(e) => println!("Failed to get history: {:?}", e),
}
```

## Best Practices

### 1. Use Limits for Large Histories

Always use the `--limit` flag or `limit` parameter to avoid loading too many transactions at once.

### 2. Refresh After Operations

Check transaction history after deposits, withdrawals, or transfers to verify completion.

## Next Steps

* [Balances Guide](./balances)
* [Deposits Guide](./deposits)
* [Error Handling](./error-handling)
* [Commands Reference](./commands)
