Skip to main content
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:
  1. Your referrer wallet in _referrers: this is who gets paid (10% of ticket fees + 10% of winnings from referred play).
  2. Your _source tag in _source: one bytes32 label for your app, the same on every call. Once allow-listed, it shows your app’s name and icon on megapot.io results.
These are independent: the referrer wallet moves money, the source tag is attribution only and never affects payments. Miss the referrer wallet and you earn nothing. Miss the source tag and your app won’t show up on megapot.io. See Get Listed to get your tag allow-listed. See Referrals & Attribution for the full model.

Weight A: Wire one flow

Keep your own UI. Call the contract that matches your scenario: 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

This 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 live referralFee and referralWinShare rates (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:
Building with an AI assistant? Point it at llms.megapot.io and it loads the right skills and recipes itself.

Next