Practice ยท 2 of 3
Transactional Transfer
Write transfer(accounts, fromId, toId, amount) โ accounts is a Map id => { balance }. Rules: missing account => { ok: false, error: "not-found" }; insufficient funds => { ok: false, error: "insufficient" } with NOTHING changed; success debits and credits and returns { ok: true }. The two writes must be atomic in effect: any failure leaves both balances untouched.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: API โ Database โ Practice