How it works
The transaction history system:- Fetches all transactions associated with your account
- Displays both swap and transfer operations
- Shows real-time transaction status
- Provides links to blockchain explorers
- Supports pagination for large transaction sets
Implementation
Transaction history page
The history page uses theTransactionHistory component:
app/(trading)/history/page.tsx
Fetching transaction history
Use theuseTransactionHistory hook to load transactions:
lib/hooks/useTransactionHistory.ts
API integration
The transactions API supports pagination:lib/api/transactions.ts
Transaction types
Two types of transactions are displayed:Swaps
Token exchanges across or within chains:components/TransactionHistory.tsx
Transfers
Cross-chain token transfers to other addresses:components/TransactionHistory.tsx
Transaction status
Each transaction has one of several status values:COMPLETED
COMPLETED
Transaction successfully executed and confirmed on all chains.
PENDING
PENDING
Transaction submitted and awaiting confirmation.
FAILED
FAILED
Transaction failed during execution.
REFUNDED
REFUNDED
Transaction failed and funds were returned.
Status indicators
Status is displayed with color-coded badges:components/TransactionHistory.tsx
Transaction details
Each transaction card is expandable to show detailed information:components/TransactionHistory.tsx
Amount formatting
Amounts are formatted based on their magnitude:components/TransactionHistory.tsx
Chain operations
Transactions include details about operations on each chain:lib/types/quote.ts
Explorer links
Each operation includes a link to the blockchain explorer:components/TransactionHistory.tsx
Pagination
Load more transactions as the user scrolls:lib/hooks/useTransactionHistory.ts
Load more button
components/TransactionHistory.tsx
Refresh functionality
Users can manually refresh their transaction history:components/TransactionHistory.tsx
Empty states
Handle cases where the user has no transactions:components/TransactionHistory.tsx
Timestamp formatting
Dates are formatted usingdate-fns:
Best practices
1
Load on authentication
Automatically fetch transaction history when the user connects their wallet.
2
Implement pagination
Load transactions in batches (10-20 at a time) to improve performance.
3
Provide explorer links
Always include links to blockchain explorers so users can verify transactions independently.
4
Show clear status indicators
Use color coding and icons to make transaction status immediately visible.
5
Handle errors gracefully
Display helpful error messages when transaction history fails to load.
Transaction history is stored by OneBalance and persists across sessions. Users can view their complete transaction history anytime they connect their wallet.