Design a Digital Wallet
👛 What is a digital wallet? It is an app that holds money for you. You move money in from your bank, send it to friends in a second, and move it back out to your bank later. Behind the app sits a ledger: a record of every cent that moved, so the app can show you a statement and can always prove that your balance is right.
This prompt comes in a few shapes: "design a bank account with deposit, withdraw and transfer", "design Venmo" (person-to-person payments), or "design a double-entry ledger". They are one design. The bank account is the account and its balance, P2P payments are transfers between two accounts in the same system, and the double-entry ledger is how we record every movement so money is never created or lost by a bug. Venmo-style "instant transfers" (cash out to your bank right now, for a small fee) come up as a follow-up, and we cover them in Extensibility.
Requirements
"Design a digital wallet. Users can add money, send money to each other, and cash out to their bank. They can see their transaction history."
The interesting parts are not in the prompt: what happens when a user is short of money, what "history" means, and what happens when a payment goes to the wrong person. Ask.
Clarifying Questions
You: Can a balance go below zero, like an overdraft?
Interviewer: No. A withdrawal or a transfer that is larger than the balance is rejected.
You: Do we talk to real banks for deposits and withdrawals?
Interviewer: Not in this round. Treat the bank as one outside party. A deposit simply arrives, a withdrawal simply leaves.
You: Are transfers between users instant?
Interviewer: Yes. Both users are inside our system, so the sender's balance goes down and the receiver's goes up in the same step. Nobody should ever see the money in both places, or in neither.
You: What should the history show?
Interviewer: Every movement on the user's account, oldest first: the type, the amount with a sign, and who was on the other side.
You: Can a payment be undone?
Interviewer: A transfer can be refunded once, in full, as long as the receiver still has the money. We never delete or edit a payment, though. Auditors need to see what happened.
You: How are amounts represented?
Interviewer: Whole cents, as integers. One currency.
You: Several requests at once?
Interviewer: Start single-threaded. We will talk about concurrency later.
The refund answer is the one that shapes the design. "Never edit a payment" means history is append-only, and a refund has to be a new record that moves money back. Once you hear that, a ledger is the natural model.
💡 Interview tip: Ask how money is represented before you write a single field. Saying "integer cents, never floats" early shows you know that
0.1 + 0.2 != 0.3, and it removes a whole class of rounding bugs from the rest of the interview.
Final Requirements
- Users open an account with balance 0. Each user has one account.
- A user can deposit money from the bank and withdraw money to the bank.
- A user can transfer money to another user. The transfer is instant: both balances change together.
- A withdrawal or transfer larger than the balance is rejected. Balances never go below 0.
- Every successful movement gets a transaction id (1, 2, 3, ... in order) and is recorded permanently.
- A user can see their balance and a statement of every movement on their account, oldest first.
- A transfer can be refunded once, in full, if the receiver still has enough money. A refund is a new transaction; the original stays as it was.
Out of scope
- Real bank integration, card networks and settlement delays (we discuss settlement in Extensibility).
- Multiple currencies, fees and interest.
- Fraud checks, KYC and limits.
- Concurrency (we come back to it in Extensibility).