By Editorial Team, reviewed by Editorial Team (approved by site owner) · Published · 2 min read
Money is where small bugs become expensive. A wallet built as a single "balance" number that gets updated in place is hard to audit and easy to corrupt.
Use a ledger, not a balance
Record every movement as an entry: deposit, bet, win, refund, bonus, withdrawal, adjustment. The balance is the sum of entries, never edited directly. Entries are append-only; a mistake is fixed with a new, opposite entry.
Double entry
Each movement has two sides, for example from the player wallet to a bets account. Totals across all accounts then always net to zero, which gives you a built-in check that nothing was created or lost.
Idempotency
Payment providers, game providers and your own services will retry. Give every operation a unique reference and store it with the entry. If the same reference arrives again, return the stored result instead of applying it twice.
Reservations
When a bet is placed or a withdrawal is requested, move the amount to a held state first, then settle or release it. This prevents spending the same funds twice and makes pending money visible to support staff.
Several balances, several currencies
Real money, bonus money and locked funds are different kinds of balance with different rules. Keep them as separate accounts. For multiple currencies, store amounts as integers in the smallest unit, record the currency on every entry, and record the exchange rate used for any conversion.
Concurrency
Two requests for the same wallet can arrive at the same moment. Use database transactions with appropriate locking or versioning so that balance checks and entries happen atomically.
Reconcile every day
Compare the ledger against payment provider statements and game provider reports. Investigate every difference, even small ones. Reconciliation is how you find problems before customers do.
Make it auditable
Log who or what caused each entry and why. Back-office adjustments should need elevated rights and leave a clear trail.
This is a design pattern, not a certified financial system. Review your accounting and regulatory requirements with qualified advisers.

