Run a contest without paying the prize twice
Snapshot the standings, pay from the snapshot, mark the contest closed — all in one transaction, with the entry rules decided before it opens.
6 entries
Snapshot the standings, pay from the snapshot, mark the contest closed — all in one transaction, with the entry rules decided before it opens.
A caller-supplied key with a unique index turns every retry, refresh and double-click into a no-op. The single most valuable column in a payments schema.
Send N, receive M, and keep the difference as the house margin. The one transaction that moves credits between two members without leaking any.
Debit on request, not on approval. The state machine that makes double payouts and phantom balances impossible.
Lock both rows in a fixed order, check inside the transaction, and write a ledger entry for each side. Skipping any of the three is how balances drift.
Reward the claim and start the next cooldown in one transaction, so a double-submitted form pays once instead of twice.