Use Smart Contracts With Basescan
The Megapot protocol operates autonomously, enabling anyone to build on it, or use it, without permission. This article covers usage via the neutral third-party app, Basescan. Use the quick links below to learn how to use the contracts directly for the given actions. If you are new to Basescan, make sure to review the Getting Started section:
Use the Contract Directly on Basescan
Getting Started
Navigate to the contract address on Basescan
Click the Contract tab, then Write Contract
Click Connect to Web3 and connect your wallet
Find the function you want to call and enter the required parameters
Contract Addresses
All contracts are deployed on Base (Chain ID: 8453).
Jackpot
0x3bAe643002069dBCbcd62B1A4eb4C4A397d042a2
Main lottery orchestrator
JackpotLPManager
0xE63E54DF82d894396B885CE498F828f2454d9dCf
Backer deposit and share management
JackpotTicketNFT
0x48FfE35AbB9f4780a4f1775C2Ce1c46185b366e4
ERC-721 ticket NFTs
JackpotAutoSubscription
0x02A58B725116BA687D9356Eafe0fA771d58a37ac
Auto-subscription management
BatchPurchaseFacilitator
0x01774B531591b286b9f02C6Bc02ab3fD9526Aa76
Batch ticket purchases
JackpotRandomTicketBuyer
0xb9560b43b91dE2c1DaF5dfbb76b2CFcDaFc13aBd
Random ticket purchases
GuaranteedMinimumPayoutCalculator
0x97a22361b6208aC8cd9afaea09D20feC47046CBD
Prize tier calculations
ScaledEntropyProvider
0x5D030DEC2e0d38935e662C0d2feD44B050c8Ae51
Pyth randomness integration
Player Functions
Buy Tickets
Contract: Jackpot (Basescan)
Function: buyTickets
Purchase lottery tickets for the current drawing.
Parameters:
_tickets: Array of ticket structs, each containing:normals: Array of 5 numbers (1 to ballMax, typically 1-30)bonusball: Single number (1 to current bonusballMax)
_recipient: Address to receive the ticket NFTs_referrers: Array of referrer addresses (can be empty[])_referralSplit: Array of split percentages in 1e18 scale (must sum to 1e18 if referrers provided)_source: Telemetry identifier (use0x0000000000000000000000000000000000000000000000000000000000000000)
Before calling:
Approve USDC spending for the Jackpot contract (1e6 per ticket)
Example: 1 ticket with numbers 1, 5, 10, 15, 20 and bonusball 3, no referrer:
Buy Random Tickets
Contract: JackpotRandomTicketBuyer (Basescan)
Function: buyTickets
Purchase tickets with randomly generated numbers. The contract handles number selection for you using on-chain randomness.
Parameters:
_count: Number of random tickets to purchase_recipient: Address to receive the ticket NFTs_referrers: Array of referrer addresses (can be empty[])_referralSplitBps: Array of split percentages in 1e18 scale (must sum to 1e18 if referrers provided)_source: Telemetry identifier (use0x0000000000000000000000000000000000000000000000000000000000000000)
Before calling:
Approve USDC spending for the JackpotRandomTicketBuyer contract (1e6 per ticket)
Example: 5 random tickets, no referrer:
Claim Winnings
Contract: Jackpot (Basescan)
Function: claimWinnings
Claim prizes from winning tickets. The ticket NFTs are burned upon claiming.
Parameters:
_userTicketIds: Array of ticket NFT IDs to claim
Before calling:
Find your ticket IDs (see below)
Ensure the drawing has completed (tickets must be from a past drawing)
How to find your ticket IDs:
Option 1: Use an NFT marketplace (OpenSea, etc.) to view your Megapot Tickets collection. The ticket ID is shown in each NFT's details.
Option 2: Query the contract directly:
Go to the JackpotTicketNFT contract on Basescan
Click the Read Contract tab
Call
getUserTicketswith your address and the drawing IDThe response includes
ticketIdfor each ticket you own in that drawing
Example calling getUserTickets for drawing 42:
Example claiming 2 tickets:
Backer Functions
Deposit to Prize Pool
Contract: Jackpot (Basescan)
Function: lpDeposit
Deposit USDC to back the prize pool and earn returns from ticket sales.
Parameters:
_amountToDeposit: Amount of USDC in wei (6 decimals, so 1000000 = $1)
Before calling:
Approve USDC spending for the Jackpot contract
Example depositing $1,000:
Initiate Withdrawal
Contract: Jackpot (Basescan)
Function: initiateWithdraw
Begin the withdrawal process. Shares are moved to pending status.
Parameters:
_amountToWithdrawInShares: Amount of shares to withdraw (6 decimals, like USDC)
Note: You can view your share balance by calling getLPShares on JackpotLPManager with your address.
Example withdrawing 100 shares:
Finalize Withdrawal
Contract: Jackpot (Basescan)
Function: finalizeWithdraw
Complete a pending withdrawal and receive USDC. Call this after the drawing completes.
Parameters: None (uses your connected wallet address)
Emergency Withdrawal
Contract: Jackpot (Basescan)
Function: emergencyWithdrawLP
Only available when emergency mode is enabled. Withdraws all LP positions immediately.
Parameters: None
Referrer Functions
Claim Referral Fees
Contract: Jackpot (Basescan)
Function: claimReferralFees
Claim accumulated referral fees from ticket sales and winner payouts.
Parameters: None (uses your connected wallet address)
Check your balance first: Call referralFees on the Jackpot contract with your address to see your claimable amount.
Auto-Subscription Functions
Create Subscription
Contract: JackpotAutoSubscription (Basescan)
Function: createSubscription
Set up automatic daily ticket purchases.
Parameters:
_recipient: Address to receive the tickets_totalDays: Number of days to subscribe_dynamicTicketCount: Number of random tickets per day_userStaticTickets: Array of static tickets (same numbers each day)_referrers: Referrer addresses_referralSplit: Referral split percentages (1e18 scale)
Before calling:
Calculate total cost:
totalDays × (dynamicTickets + staticTickets) × ticketPriceApprove USDC spending for the JackpotAutoSubscription contract
Example: 30-day subscription with 2 random tickets + 1 static ticket (1, 5, 10, 15, 20 with bonusball 3) per day, no referrer:
Cancel Subscription
Contract: JackpotAutoSubscription (Basescan)
Function: cancelSubscription
Cancel your subscription and receive a refund for unused days.
Parameters: None (uses your connected wallet address)
Batch Purchase Functions
Create Batch Order
Contract: BatchPurchaseFacilitator (Basescan)
Function: createBatchOrder
Create a batch order for purchasing many tickets at once.
Parameters:
_recipient: Address to receive the tickets_dynamicTicketCount: Number of randomly generated tickets_userStaticTickets: Array of user-defined tickets_referrers: Referrer addresses_referralSplit: Referral split percentages
Before calling:
Calculate total cost:
totalTickets × ticketPriceApprove USDC spending for the BatchPurchaseFacilitator contract
Example: 50 random tickets + 2 static tickets (7, 14, 21, 28, 30 with bonusball 5) and (2, 4, 6, 8, 10 with bonusball 1), no referrer:
Cancel Batch Order
Contract: BatchPurchaseFacilitator (Basescan)
Function: cancelBatchOrder
Cancel a pending batch order and receive a full refund.
Parameters: None (uses your connected wallet address)
Read Functions
These view functions help you check state before making transactions:
currentDrawingId
Jackpot
Current drawing number
getDrawingState(drawingId)
Jackpot
Drawing details (prizePool, ticketPrice, bonusballMax, etc.)
ticketPrice
Jackpot
Current ticket price in USDC wei
referralFees(address)
Jackpot
Claimable referral fees for an address
getLpInfo(address)
JackpotLPManager
LP position details (shares, deposits, withdrawals)
getLPValueBreakdown(address)
JackpotLPManager
USDC-denominated breakdown of LP position
getSubscriptionInfo(address)
JackpotAutoSubscription
Subscription details
getBatchOrderInfo(address)
BatchPurchaseFacilitator
Batch order details
Approving USDC
Many Megapot functions require you to approve USDC spending before calling them. This is a standard ERC-20 pattern that allows the contract to transfer USDC on your behalf.
USDC on Base: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
How to Approve
Go to the USDC contract on Basescan
Click the Write as Proxy tab
Connect your wallet
Find the
approvefunctionEnter the parameters:
spender: The Megapot contract address you want to interact with (see table below)value: The amount in USDC wei (6 decimals)
Click Write and confirm the transaction
Amount Examples
$1
1000000
$10
10000000
$100
100000000
$1,000
1000000000
Which Contract to Approve
Buy tickets
Jackpot
0x3bAe643002069dBCbcd62B1A4eb4C4A397d042a2
Buy random tickets
JackpotRandomTicketBuyer
0xb9560b43b91dE2c1DaF5dfbb76b2CFcDaFc13aBd
Deposit to pool
Jackpot
0x3bAe643002069dBCbcd62B1A4eb4C4A397d042a2
Create subscription
JackpotAutoSubscription
0x02A58B725116BA687D9356Eafe0fA771d58a37ac
Create batch order
BatchPurchaseFacilitator
0x01774B531591b286b9f02C6Bc02ab3fD9526Aa76
Need Help?
Ask our Support Chat if you have any questions about direct contract interactions.
Last updated
