What is a double-entry ledger?

A double-entry ledger records every movement of money as a transaction with at least two entries, debits and credits, that must total the same amount. Money can't appear or vanish, and every balance can be traced to its entries.

Also called double-entry accounting, double-entry bookkeeping, ledger system, double-entry ledger systemUpdated

Many products start by storing a balance column on each user and adding or subtracting from it. It works until a refund runs twice, a crash lands between two updates, or nobody can explain why a balance is ₹312. A double-entry ledger fixes this with a rule accountants have used for centuries: every movement of money is recorded in at least two accounts, and the debits equal the credits. In software the ledger is a set of tables. Accounts hold money: customer wallets, merchant payables, bank clearing, fee revenue, suspense. Transactions group entries, and each entry debits or credits one account. A transaction is only accepted if its entries balance. An account's balance is the sum of its entries.

How debits and credits work

Each account has a normal side. Asset accounts, such as cash at the bank, increase with a debit. Liability accounts, such as money you hold for customers, increase with a credit. A wallet balance is a liability for the wallet provider, because it owes that money to the customer. That's why a top-up credits the customer's wallet account.

Example: journal entries for a wallet payment

A customer adds ₹1,000 to a wallet by UPI, then pays a merchant ₹600, and the platform keeps a ₹12 fee. Amounts are stored as integers in paise.

Txn Account Debit Credit
T1 top-up Bank clearing (asset) 1,00,000
T1 top-up Customer wallet (liability) 1,00,000
T2 payment Customer wallet (liability) 60,000
T2 payment Merchant payable (liability) 58,800
T2 payment Fee revenue (income) 1,200
Total 1,60,000 1,60,000
Each transaction balances on its own: T1 is 1,00,000 = 1,00,000, and T2 is 60,000 = 58,800 + 1,200. The wallet balance is 1,00,000 − 60,000 = 40,000 paise, or ₹400, and every rupee of it can be traced. When the merchant is paid out, a T3 debits merchant payable and credits bank clearing.

Design rules for a software ledger

  • Integers, not floats. Store paise or cents with a currency code on every entry.
  • Append-only. Never update or delete an entry. Correct mistakes with a reversal transaction, then post the right one.
  • Enforce balance in the database transaction. Write all entries of a transaction atomically, and reject any set that doesn't sum to zero.
  • Idempotent posting. Give each transaction a unique external reference, so a retried request or replayed webhook can't post twice. See idempotency.
  • Lock or version the debited account, so two concurrent payments can't spend the same ₹400.
  • Model money in transit. Pending UPI or card payments sit in clearing or hold accounts until the provider confirms them.
  • Derive balances. A cached balance is fine for speed, but a daily job should recompute it from entries and alert on any difference.

Where it's used

Wallets, marketplaces with split settlements, lending platforms tracking principal, interest and fees in a loan management system, and payment companies holding merchant funds. A ledger tells you what should be true. Payment reconciliation checks it against bank and gateway reports.

Double-entry ledger vs event sourcing

Both are append-only. Event sourcing stores every change to any kind of object as an event. A double-entry ledger is a specific, stricter model for money, with the balancing rule built in. Many FinTech systems use both: events for workflow, ledger for money. For a full design walkthrough, read how to design a payments ledger that reconciles.

Any idea in mind? Let's make it real.

Tell us what you're building. You'll hear back from an engineer, not a sales team, usually within one working day.

Book a 30-min call