01
Idempotency
Every money-moving request carries an idempotency key. Retries, timeouts and duplicate webhooks produce exactly one effect — a replay just returns the original result.
POST /transfers Idempotency-Key: 7f3a…c1 → 201POST /transfers Idempotency-Key: 7f3a…c1 → 201 (replay)
02
ACID transactions
A balance change and its ledger entries commit together or not at all. The isolation level is a deliberate choice per flow, not whatever the ORM defaults to.
BEGIN; INSERT INTO entries …; UPDATE balances …;COMMIT; -- both or neither
03
Race conditions
Two withdrawals hitting one account in the same millisecond cannot both win. Conditional updates, row locks or optimistic versions — then proven under parallel load.
UPDATE accounts SET balance = balance - $1 WHERE id = $2 AND balance >= $1;-- 0 rows updated → reject, never overdraw
04
Sagas & outbox
Flows that span services and partners — debit, payout, confirm — run as sagas with compensating steps. Events leave through a transactional outbox, so a rollback never gets announced.
debit ✓ → payout ✗ partner timeoutrefund ✓ → state: compensated
05
Reconciliation
The internal ledger is checked against bank statements and on-chain state every day. A mismatch is flagged and investigated — never silently patched.
ledger 1,204,551.20 EUR = bank ✓ledger 41.92710553 BTC = on-chain ✓
06
Integer minor units
Amounts are stored and calculated as integers in the smallest unit — cents, satoshis, wei, lamports — with BigInt or decimal types. Never floating point.
0.1 + 0.2 = 0.30000000000000004 ✗10n + 20n = 30n cents ✓1 BTC = 10⁸ sat · 1 ETH = 10¹⁸ wei · 1 SOL = 10⁹ lamports