After some previous experimentation with Lucky Number, a very simple lottery type of game, we quickly realized that it had very poor incentive mechanics and some ways to exploit the game in itself.
So, I’ve been working on an updated and more economically viable lottery type game more in line with the popular Pancake Swap Lottery (PancakeSwap).
In summary, this is a lottery where users buy tickets that have a sequence of 6 digits. If the digits on those tickets match the winning digits in the correct order of the drafted ticket, users win a portion of the prize pool allocated to that specific sequence. A lottery round is approximately 12 hours from start to finish.
The main functionality is described below:
Buy Tickets: Users buy N Tickets with a sequence of 6 digits
- Users can choose digits manually or the frontend randomly selects the digits of the tickets
- Tickets are not refundable, once bought they cannot be given back
- There is a bulk discount applied automatically to the ticket price incase multiple tickets are bought at the same time
- Frontend limits the number of tickets per transaction with 500 (mainly due to gas cost limitations), but user can have as many tickets as they want on a specific round (user can buy 500 tickets then another 500 tickets…)
Staking: Prize Pot accumulates and is directly staked on the SEFI stake contract
- When users buy tickets, the contract receive their tokens and deposit them on the staking contract
Round Triggers: Lottery Rounds are approximately 12 hours from start to finish (these can only be called by a specific address)
- Trigger Close Round
- Draft Winning Ticket Digits
- Unstake all the prize pool
- Redeem from the staking contract
- Rewards are collected automatically too
- Trigger End and Start Round
- Allocate tokens to reward pot
- Allocate tokens to burn + burn tokens
- Allocate tokens to triggerer + transfer tokens to triggerer
- Allocate Jackpot Tokens to new round + Deposit them on the staking SEFI contract
- Start new round
- Trigger Close Round
Claim Rewards: Users can claim rewards for their winning ticket
- Users can claim each ticket individual or multiple tickets on the same transaction
- Claim tokens come from the reward pot of that specific round
Here are the main functions and respective flows that the contract executes:
Currently there is a holodeck-2 testnet version here: https://thatrand0muser.github.io/
This is just a staging version so we can already mess around with the lottery and test all of its functionality. For a mainnet version of the frontend it will be more inline with the secret network design patterns.
Contract: GitHub - ThatRand0mUser/secret-lottery
Would really love some feedback on this!