> ## 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 in the Privacy Boost WASM SDK.

## Basic Usage

```typescript theme={null}
const transactions = await sdk.getTransactionHistory();
for (const tx of transactions) {
  console.log(`${tx.txType}: ${tx.amount} - ${tx.txHash}`);
}
```

## Transaction Type

```typescript theme={null}
interface Transaction {
  txHash: string;
  txType: 'deposit' | 'withdraw' | 'transfer';
  tokenAddress: string;
  amount: string;           // Amount in wei
  direction: 'in' | 'out';
  senderPubKey: string;
  receiverPubKeys: string[];
  createdAt: number;        // Unix timestamp
}
```

## Filtering History

### By Transaction Type

```typescript theme={null}
const deposits = await sdk.getTransactionHistory({ type: 'deposit' });
const withdrawals = await sdk.getTransactionHistory({ type: 'withdraw' });
const transfers = await sdk.getTransactionHistory({ type: 'transfer' });
```

### By Token

```typescript theme={null}
const usdcHistory = await sdk.getTransactionHistory({
  tokenAddress: '0x...usdc-address',
});
```

### With Limit

```typescript theme={null}
const recent = await sdk.getTransactionHistory({ limit: 10 });
```

### Combined Filters

```typescript theme={null}
const recentUsdcDeposits = await sdk.getTransactionHistory({
  type: 'deposit',
  tokenAddress: '0x...usdc-address',
  limit: 5,
});
```

## Filter Parameters

| Parameter | Type | Description |
| - | - | - |
| `type` | `string?` | Filter by type: `"deposit"`, `"withdraw"`, `"transfer"` |
| `tokenAddress` | `string?` | Filter by token contract address |
| `limit` | `number?` | Maximum number of results |

## Displaying Transactions

```typescript theme={null}
const transactions = await sdk.getTransactionHistory({ limit: 20 });

for (const tx of transactions) {
  const date = new Date(tx.createdAt * 1000).toLocaleString();
  const formatted = sdk.formatAmount(tx.amount, 18);
  console.log(`[${date}] ${tx.txType}: ${formatted} (${tx.direction})`);
}
```

## Error Handling

```typescript theme={null}
try {
  const transactions = await sdk.getTransactionHistory();
} catch (error) {
  if (error.message.includes('Not authenticated')) {
    console.log('Please log in first');
  } else if (error.message.includes('Network error')) {
    console.log('Network error, please retry');
  } else {
    console.log('Failed to get history:', error.message);
  }
}
```

## Best Practices

### 1. Paginate Results

Use the `limit` parameter to load transactions in pages for better performance.

### 2. Refresh After Operations

Fetch updated history after deposits, withdrawals, or transfers.

## Next Steps

* [Balances Guide](./balances)
* [Deposits Guide](./deposits)
* [Error Handling](./error-handling)
* [API Reference](/sdk/wasm/api-reference)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.