💰
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 Gift Tickets
  • Walkthrough
  • Example
  • Getting Purchased Tickets Info
  1. Developer Reference
  2. Megapot Examples

Gifting Tickets

PreviousRefer TicketsNextBrand Kit

Last updated 15 hours ago

Programmatically gift tickets to your members or community! Incentivize your dapp. Reward your users for just $1, it's easy and cheap to reward loyalty. You can gift tickets to a different wallet by setting the recipient parameter to the wallet you want to gift the tickets to.

How to Gift Tickets

Megapot's contract allows you to gift tickets to the jackpot from your site. This is done by adding your wallet address as the referrer parameter to the ticket purchase function and adding the recipient parameter to the ticket purchase function of the wallet you want to gift the tickets to.

View our example code.

Walkthrough

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 receiving the ticket(s).

Just set yourself as the referrer parameter and the recipient parameter to the wallet you want to gift the tickets to.

Example

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

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

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

Getting Purchased Tickets Info

usersInfo(address user)
uint256 ticketsPurchased = usersInfo.ticketsPurchasedTotalBps / 7000;

You can get the number of tickets purchased by a wallet by calling the function with the recipient wallet address as the parameter.

This will return some data about the wallet. The ticketsPurchasedTotalBps is the number of tickets purchased by the wallet this round. To get the number of tickets purchased, you can divide this number by 7000. Our contract uses a basis points number to calculate tickets in the contract. Every ticket is worth 10_000 ticket units (See our ). 30% of the ticket price goes to LPs & referral fees. So to calculate the number of tickets purchased, you divide the total bps by 7000.

Gifting Tickets
usersInfo
deep dive