Gifting Tickets
Last updated
Last updated
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.
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.
Let's take a look at the purchaseTickets function:
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.
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.
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.