💰
Megapot
  • Overview
    • About Megapot
    • How to play
    • How to provide liquidity
    • How to refer users
    • Earn as a liquidity provider
    • About the Team
    • Megapoints
  • Deep dive
    • Components
    • System Diagram
    • Smart Contract
    • Provably Fair
  • Developers
    • Start Here
    • React UI Kit (Beta)
      • MegapotProvider
      • Jackpot
      • useJackpot
    • Standalone Integration
      • Getting Started
      • Contract Functions
      • Jackpot Page
      • LP Deposit Page
      • History Page
    • Custom ERC-20 Jackpot
  • Developer Reference
    • Testnet & Mainnet
    • Contract Overview & Functions
    • Megapot API
    • Megapot Examples
      • Refer Tickets
      • Gifting Tickets
    • Brand Kit
  • Appendix
    • VIP Program
    • FAQ
    • About Megapot
  • Terms of Service
  • Privacy Policy
  • Responsible Gaming
Powered by GitBook
On this page
  • How to Refer Tickets
  • Example
  • Claiming Referral Fees
  • Viewing Referral Fees
  • UI Kit React/Next.js Implementation
  1. Developer Reference
  2. Megapot Examples

Refer Tickets

Anyone can be a Megapot partner! We make it easy to sell tickets to the Megapot jackpot from your site. You can earn 10% of every ticket purchase your users make. Claimable immediately through the contract. By simply adding your wallet address as the referrer in ticket purchases from your site you can begin earning immediately.

How to Refer Tickets

Megapot's contract is designed for you to be able to refer tickets to the jackpot from your site. This is done by adding your wallet address as the referrer parameter to the ticket purchase function.

Let's take a look at the purchaseTickets function:

purchaseTickets(address referrer, uint256 value, address recipient)
  • referrer: Your wallet address. Triggers the contract to pay you 10% of the ticket price for each ticket purchased.

  • value: The number of tickets to purchase, in szabo (6 decimals). 1_000_000 szabo = 1 ticket.

  • recipient: The address of the recipient of the tickets. This is the wallet of the person purchasing the tickets.

As you can see, it is very simple to refer tickets. Just set yourself as the referrer parameter.

Example

Let's say you want to refer 10 tickets to the jackpot. You would set the referrer parameter to your wallet address and the value parameter to 10 tickets.

purchaseTickets(
    address referrer,
    uint256 value,
    address recipient
);

purchaseTickets(
    0x1234567890123456789012345678901234567890, // referrer
    10_000_000,                                 // value
    0x7890123456789012345678901234567890123456  // recipient
);

Claiming Referral Fees

This will withdraw the referral fees to your wallet address directly from the contract. You can call this function as often as you want.

Viewing Referral Fees

referralFeesClaimable(address user)

This will return the amount of referral fees you have earned in szabo. A number of 1_000_000 = $1 USDC

UI Kit React/Next.js Implementation

Here is a sample implementation of the refer tickets functionality in a React/Next.js application using the Megapot UI Kit.

import {
  Jackpot,
  MainnetJackpotName,
  MegapotProvider,
  JACKPOT,
  TestnetJackpotName,
} from '@coordinationlabs/megapot-ui-kit';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { createConfig, http } from '@wagmi/core';
import { base, baseSepolia } from 'viem/chains';
import { WagmiProvider, useConnect } from 'wagmi';

const referrer = '0x1234567890123456789012345678901234567890'; // Replace with your wallet address

const queryClient = new QueryClient();

const wagmiConfig = createConfig({
  chains: [base, baseSepolia],
  transports: {
    [base.id]: http(),
    [baseSepolia.id]: http(),
  },
});

function MegapotWrapper({ children }) {
  const { connectors } = useConnect();

  // You can use any wallet provider
  return (
    <MegapotProvider
      onConnectWallet={() => {
        connectors[0].connect();
      }}
    >
      {children}
    </MegapotProvider>
  );
}

const App = () => {
  return (
    <QueryClientProvider client={queryClient}>
      <WagmiProvider config={wagmiConfig}>
        <MegapotWrapper>
          {/* Base Mainnet */}
          <Jackpot
            contract={JACKPOT[base.id]?.[MainnetJackpotName.USDC]}
            referrerAddress={referrer}
          />
          {/* Base Sepolia */}
          {/* <Jackpot
            contract={JACKPOT[baseSepolia.id]?.[TestnetJackpotName.MPUSDC]}
            referrerAddress={referrer}
          /> */}
        </MegapotWrapper>
      </WagmiProvider>
    </QueryClientProvider>
  );
};

export default App;
PreviousMegapot ExamplesNextGifting Tickets

Last updated 16 hours ago

Referral fees are claimable immediately through the contract. You can claim your referral fees by calling the function.

You can view your referral fees by calling the function with your wallet address as the parameter.

withdrawReferralFee
referralFeesClaimable
Megapot UI Kit Docs