Skip to content

Transaction History (Strict Ledger)

The SDK provides access to the user's immutable transaction ledger. This is scoped per walletId and uses a strict accounting schema to ensure full audit compliance.

Fetching Transactions

You must provide the walletId. You can also paginate and filter by transaction type.

javascript
const transactions = await sdk.wallet.getTransactions('wallet_usd', {
  limit: 20,
  offset: 0,
  type: 'DEPOSIT' // Optional: Filter by DEPOSIT, WITHDRAWAL, BET, WIN, etc.
});

transactions.forEach(tx => {
  console.log(`${tx.direction} ${tx.amount} ${tx.currency} - ${tx.status}`);
});

Strict Ledger Schema

Every financial movement in the platform uses this exact schema. Your backend database must implement this structure.

typescript
interface Transaction {
  id: string;
  walletId: string;
  type: 'DEPOSIT' | 'WITHDRAWAL' | 'BET' | 'WIN' | 'BONUS_CREDIT' | 'BONUS_EXPIRY' | 'REFUND' | 'ADJUSTMENT';
  
  // Accounting Logic: Amount is ALWAYS a positive number.
  // Direction dictates whether money was added (CREDIT) or removed (DEBIT).
  direction: 'CREDIT' | 'DEBIT'; 
  amount: number; 
  
  currency: string;
  status: 'PENDING' | 'COMPLETED' | 'FAILED' | 'REJECTED';
  
  // The real balance of the wallet immediately AFTER this transaction was applied.
  // Crucial for casino auditors to trace the exact flow of funds.
  balanceAfter: number; 
  
  reference?: string; // e.g., Game Round ID or Provider Transaction ID
  metadata?: Record<string, any>;
  createdAt: string;   // ISO 8601 Date string
}

Audit Trail Integrity

Even rejected or failed transactions (like a withdrawal denied due to insufficient funds) are recorded in the ledger with a REJECTED or FAILED status. This ensures a complete audit trail for casino compliance.