Anyone can write a script that picks random numbers. A lottery platform you can run as a business needs more than that: prize tiers that are funded, draws you can explain, a plan for slow sales, and a record of everything. This guide is about those parts. It uses RaffKing, our self-hosted lottery and raffle script, for concrete examples, and it's honest about the gaps.
Running a lottery for money is regulated almost everywhere, and in many places it's reserved for state or licensed operators. Licensing is your responsibility. Nothing here is legal advice: check with a local lawyer before you sell a ticket, and never market a paid draw to anyone under 18.
Number-match draws vs ticket raffles
There are two common designs:
- Number-match lottery. Players pick numbers, numbers are drawn, and prizes depend on how many match. In RaffKing that's the Pick numbers type: players choose between 1 and 10 numbers, each from 1 to 49.
- Ticket raffle. Tickets are sold, one or more are drawn, and the drawn tickets win. RaffKing has a Raffle type as well. Our raffle script buyer's guide covers the checks for that model.
The rest of this article is about number-match draws, because that's where the maths can surprise you.
The odds, and why they decide your prize tiers
The chance of matching depends on how many numbers each ticket has. Here are the exact odds for a ticket of 3, 5 or 6 numbers drawn from 1–49:
| Numbers per ticket | Match all | Match all but one | Match all but two |
|---|---|---|---|
| 3 of 49 | 1 in 18,424 | 1 in 133.5 (2 of 3) | 1 in 5.9 (1 of 3) |
| 5 of 49 | 1 in 1,906,884 | 1 in 8,668 (4 of 5) | 1 in 202 (3 of 5) |
| 6 of 49 | 1 in 13,983,816 | 1 in 54,201 (5 of 6) | 1 in 1,032 (4 of 6) |
Two things follow for a small operator:
- A 6-of-49 top prize will almost never be won on a small site. With a few thousand tickets per draw, players will notice that nobody ever wins. Fewer numbers per ticket give odds your audience can actually see someone beat.
- Every matching ticket wins its tier. In RaffKing you attach a prize to each range of matches (for example, 3 matches wins X and 2 matches wins Y), and every ticket that lands in that range gets that prize. Several tickets can win the same tier in one draw, so make sure you can pay out if they do.
Check the expected payout before you publish
For each tier, multiply the chance by the prize and add them up. That gives the average paid out per ticket. Here's an illustrative example (not a recommendation) for a 3-of-49 ticket costing 100 coins, with prizes of 50,000 coins for 3 matches and 500 coins for 2:
50,000 ÷ 18,424 + 500 × 138 ÷ 18,424 ≈ 6.5 coins per ticket
On average that pays back about 6.5% of ticket revenue as prizes. That's very little, and many regulators set a minimum share that must go to prizes or good causes. Decide the payout you intend, check it against your licence conditions, and set the tiers to match. Never advertise a prize level you haven't funded.
Draws: verified, automatic or manual
- Verified (on for a new store). Each draw is committed to a secret seed when it's made, and only the seed's fingerprint is shown. After the draw closes, its numbers come from that seed, the list of tickets that could win and public randomness from drand published after the close, so nobody, the store included, can choose or foresee them. Each draw's Verify page lets anyone recalculate the result. While Verified draws are on, the two modes below aren't used: manual draws and editing winning numbers are off. Switch it under Plugins › Lottery.
- Automatic, with Verified draws off. At the draw time, a scheduled job draws the numbers with PHP's cryptographically secure
random_int()and works out the winners. Cron has to be running on your server. - Manual, with Verified draws off. You enter the winning numbers yourself under Lottery › Winners. You can change them until the draw time, and customers don't see them. Every change is logged with the old and new values. This is the mode to use if your regulator requires an independent or live draw: you enter the official result.
Only verified draws can be checked by players themselves. Whichever you use, what also protects players is publishing results, keeping the admin log, and locking settings once money is taken. RaffKing locks the type and ticket settings once tickets are sold, and the draw method and prizes once winners are declared.
Slow sales: auto-extend
Draw times arrive whether or not tickets have sold. With Verified draws off, RaffKing can move a draw back by itself if sales are below a minimum: after N hours, up to M times. After that it either keeps extending or waits for you to draw by hand. State this rule in your terms so players know a draw can move. With Verified draws on, auto-extend never moves a draw's end, because the UK's DCMS code for prize draws (2.5) asks operators not to move a draw because of low sales. Before a verified draw closes, the store can convert it to an ordinary draw, publicly marked "Not verified", or cancel it and refund every ticket in full.
What players see
- Live ticket feed. RaffKing includes a small rotating "recent purchases" widget on each live draw's page.
- Their tickets and results. Players see their tickets, and the drawn numbers once the draw is done. Coin prizes go to their wallet automatically, and item prizes wait in My winnings to be claimed.
- Printable tickets. A printable receipt with a QR verification code is available as a separate add-on from Add-ons in your admin panel (it isn't included in RaffKing).
Payments by market
Players buy tickets with wallet coins, which they top up through your payment gateways. RaffKing includes 11 gateways (Stripe, PayPal, Razorpay, PayU, 2Checkout, Authorize.net, Checkout.com, Mollie, GoCardless, Cashfree, Instamojo), plus a manual method for bank transfer or local QR payments. Regional gateways such as Paystack, Flutterwave, M-Pesa and Mercado Pago are separate add-ons, available from Add-ons in your admin panel.
The harder question is whether a processor will accept a lottery business at all. Many restrict games of chance, so read the acceptable-use policy and expect to show your licence.
Licensing
Who can run a lottery, and under what licence, differs by country and sometimes by region within a country. Official starting points include the UK Gambling Commission, the UAE's GCGRA and the Philippines' PAGCOR. In India, the Promotion and Regulation of Online Gaming Act, 2025 bans online money games. For anywhere, check with a local lawyer. Our online lottery business guide covers what to ask.
Buyer's checklist
- Your lawyer has confirmed you can run paid draws where your players are.
- A payment processor has agreed to work with you, and the script supports it.
- You can set prize tiers by number of matches and check the expected payout.
- The vendor can explain exactly how numbers are drawn, and there's a manual mode for independent draws.
- Settings lock once tickets are sold, and every admin change is logged.
- There's a plan for slow sales.
- You can read the source and know what it connects to outside your server. RaffKing, for example, talks to our licence and update server.
- Your host runs PHP 8.2+, MySQL or MariaDB, and cron.
Common questions
What are the odds of matching 6 numbers from 49?
1 in 13,983,816 for a ticket of 6 numbers. Matching 5 of 6 is about 1 in 54,201, and 4 of 6 about 1 in 1,032.
Can more than one ticket win the same prize?
Yes. In RaffKing, every ticket whose number of matches falls in a prize's range wins that prize, so budget for several winners in a tier.
How are lottery numbers drawn in RaffKing?
On a new store, Verified draws are on: each draw is committed to a secret seed when it's made, and its numbers come from that seed and public drand randomness published after the close, so anyone can check them on the draw's Verify page. With Verified draws off, automatic draws use PHP's random_int() at the draw time, and manual draws let you enter numbers from an independent source, with every change logged.
Do I need a licence to run an online lottery?
Almost certainly, and in many countries private lotteries aren't allowed at all. Check with a local lawyer before you launch.