An in-app wallet and coins system lets users buy or earn virtual credits and spend them on actions inside your product: a boost, a premium message, a gift, a unlock. It looks like a small feature, but it holds something users treat as money, so errors cost trust quickly.
This guide explains how to design virtual currency properly: the rules, the data model, the failure cases and the policy risks. It uses examples from our work on the Hmm Dating app, which includes a coin wallet.
Why use coins instead of direct payments?
Coins decouple purchase from use. Users buy a pack once and then make many small spends without going through checkout each time. That is smoother for low-value actions, and it lets you price features flexibly, for example five coins for a boost.
The trade-off is responsibility. Once users hold a balance, you must keep it accurate, explain it clearly and handle disputes. Decide whether coins are worth that complexity or whether a subscription or one-time purchase is enough.
What rules should you write before building?
Write the economy as plain rules. Developers cannot guess them, and gaps become bugs and support tickets.
- How coins are obtained: purchase, bonus, reward, referral
- What coins can be spent on, and the price of each action
- Whether bonus coins and purchased coins behave differently
- Whether coins expire, and how users are told
- Refund policy for unused coins and for failed actions
- Limits: maximum balance, daily spend, minimum purchase
- What happens to balances when an account is deleted or banned
How should the ledger be designed?
Never store a coin balance as one number you overwrite. Store every change as an entry in a ledger: a row that says who, how many coins, in which direction, why and when. The balance is the sum of the entries, or a cached total that you can always check against them.
A hypothetical example: a user buys 100 coins (plus 100), spends 20 on a boost (minus 20), and gets 5 back after a failed action (plus 5). The ledger shows three entries and a balance of 85, and any support agent can trace how it got there.
Entries should be append-only. If a mistake happens, add a correcting entry instead of editing history. That is how accountants think, and it gives you an audit trail.
How do you stop double spends and double charges?
Networks fail and users double-tap. Without protection, a retry can deduct coins twice or grant them twice. The standard answer is an idempotency key: each spend or purchase carries a unique ID, and the server ignores a second request with the same ID.
Two requests might also arrive at the same moment. Use database transactions and row locks, or equivalent, so that the balance check and the deduction happen as one step. Test these cases deliberately; they are rare in normal use and common at scale.
How do purchases, webhooks and refunds fit together?
Buying coins involves a payment provider or an app store. Credit the coins only after the payment is confirmed, preferably through a server-side verification or a webhook, not just the app saying it worked.
Refunds need a rule. If a user has already spent the coins, should the refund be denied, partial or create a negative balance? Choose and document it. Our article on payment gateway integration in India explains webhooks and reconciliation, which apply directly here.
What should you check about app store policy?
App stores have rules about selling digital goods and virtual currency, including which payment systems you must use inside the app. These rules differ by store and change over time, so check the current Google Play and Apple policies and take advice if unsure.
Do not assume that a payment method that works on your website is allowed in the app. Planning this early avoids rejection at review. See our guides on publishing on Google Play and publishing on the App Store.
How does this look in a real product?
In the Hmm Dating app, users have a coin wallet alongside subscriptions, and the wallet supports premium actions. The lesson from building it is the same as above: define the rules, treat the balance as a ledger, and make every action safe to retry. You can read the Hmm Dating case study for the product context.
If you are building a dating or social product, our dating app development guide shows where a wallet fits in the wider feature set.
Next step: write your coin economy on one page
Before development, list the ways coins come in, the ways they go out and the exceptions. One clear page saves weeks of rework.
Add it to our free project brief builder and the Elevenmonk team can help turn it into a ledger design and a build plan. This is general information, not legal or tax advice.
Frequently asked questions
Are virtual coins legally the same as money?
That depends on how the coins work, whether they can be cashed out or transferred, and the law where you operate. Closed-loop coins used only inside your app are treated differently from instruments that can be withdrawn. Take advice from a qualified lawyer before launch.
Should coins expire?
Expiry can reduce liability and encourage use, but it can annoy users and may be restricted in some places or by store rules. If you add it, state it clearly before purchase and show expiry dates in the wallet. Get legal advice for your market.
Can I keep the balance as a single number in the database?
You can cache it for speed, but the source of truth should be a ledger of entries. A lone number hides mistakes and cannot explain a dispute. With a ledger you can recompute the balance and trace every change.
How do I test a wallet properly?
Test retries, simultaneous spends, failed payments, delayed webhooks, refunds and account deletion. Run a daily check that compares balances with ledger totals. These edge cases matter more than the happy path.
Want help with this? Let’s talk.
Tell us what you are planning. A founder or senior engineer replies with honest next steps, from Mumbai, for clients across India and worldwide.
Prefer to share your idea in writing? Use the free project brief builder: answer a few questions and send the brief on WhatsApp in one tap.