Add the Jackpot to Your Site
You already have a product. This page shows how to drop Megapot buy and claim into it, and earn fees on every ticket your users buy, without rebuilding your app around it.
See it working first. The full reference app is live at demo.megapot.io against Base mainnet. Click through buy, claim, and history before you write a line of code.
Pick the path that fits how much you want to build:
Wire one flow: keep your own UI, call the contracts directly. Best when you want buy or claim inside an existing screen.
Fork the starter kit: a complete five-page React app you rebrand and ship. Fastest path to a full lottery experience.
Earn on every purchase
Whichever path you choose, set two things on every purchase:
Your referrer wallet in
_referrers: this is who gets paid (10% of ticket fees + 10% of winnings from referred play).A
_sourcetag in_source: a free-formbytes32label for your own analytics.
These are independent: the referrer wallet moves money, the source tag is telemetry only and never affects payments. Miss the referrer wallet and you earn nothing. See Referrals & Attribution for the full model.
Weight A: Wire one flow
Keep your own UI. Call the contract that matches your scenario:
Up to 10 custom-number tickets
Jackpot.buyTickets
Immediate
Random / quick-pick
JackpotRandomTicketBuyer.buyTickets
Immediate
More than 10 tickets
BatchPurchaseFacilitator.createBatchOrder
Keeper-executed
Recurring across drawings
JackpotAutoSubscription.createSubscription
Keeper-executed
Addresses and full signatures for all four are in the Protocol Reference. Each carries a trailing bytes32 _source and the _referrers / _referralSplit pair.
One representative flow: Jackpot.buyTickets
Jackpot.buyTicketsThis is the common case: up to 10 custom tickets, minted immediately. The pattern (read price → approve USDC → call with referrer + source) is the same for the other three methods; only the contract and arguments change.
Confirm the exact signature and ABI at llms.megapot.io/abi/Jackpot.txt before shipping.
Showing prize info
Read live values rather than hardcoding anything:
Jackpot.getDrawingState()→ current prize pool,ticketPrice,ballMax,bonusballMax, plus the livereferralFeeandreferralWinSharerates (1e18 precision).GuaranteedMinimumPayoutCalculator(the PayoutCalculator) → expected per-tier payouts for display.
Both addresses are in the Protocol Reference.
Claiming winnings
Surface a claim in your UI and call Jackpot.claimWinnings(uint256[] _ticketIds) with the user's winning ticket IDs. For win-detection, auto-compound, and claiming your own referral fees, see Claim winnings & fees.
Don't re-narrate the whole protocol here. For batch orders, subscriptions, auto-compound, LP, and read-state multicalls, point your editor at llms.megapot.io for AI-ready viem and wagmi recipes, and use the Protocol Reference for addresses and full signatures.
Weight B: Fork the starter kit
Want a complete app, not a single flow? The Megapot Starter Kit is a five-page React + wagmi reference frontend (Home, Play, Tickets, LP, History) implementing every core flow. It's the exact app running at demo.megapot.io. MIT licensed.
Set VITE_REFERRER_ADDRESS to your wallet and the source tag in config, rebrand, and ship. A dev-mode warning fires while the referrer or source tag is still the placeholder, so you can't accidentally deploy without attribution.
The kit ships three API-key deployment shapes: anonymous (no key), browser key (VITE_MEGAPOT_API_KEY), or server proxy (key stays server-side). Pick once per fork.
Everything else lives in the repo, don't look for it here:
Repository + README: quickstart and the three deploy shapes
docs/CUSTOMIZE.md: every rebrand seam in one checklist
docs/ARCHITECTURE.md: API/RPC split, polling cadence, decisions
Live demo: the running kit on Base mainnet
Building with an AI assistant? Point it at llms.megapot.io and it loads the right skills and recipes itself.
Next
Start Here: the lay of the land
Build on the protocol: the deeper integration path
Referrals & Attribution: how the money and the source tag work
Protocol Reference: addresses and full method signatures
Pull data: the read-only Data API
Last updated

