How are lucky winners chosen?
Learn more about our operations
In this writing, we would technically describe how the protocol randomly and transparently opts the lucky users at the end of each epoch.
In the post "How are users' winning possibilities calculated?", we have explained how their ticket amounts each round are calculated. With that given, ticket amount of each user would be used to explain how the lucky winners are opted each epoch.
First of all, let's assume:
Drake's userID stored in our smart contract is 1, and he got 500 tickets in Epoch 0
Kanye's userID is 2, and he got 1000 tickets in Epoch 0
The total amount of tickets in Epoch 0 is 115,000
Regarding userID, this would increase when there is a new user and this won't affect the randomness and the chances of winning of each user. For example, Drake is the first one participating the the protocol, his userID would be 1. Kanye is the second one and his userID would be 2.
With the above data retrieved from the chain, our bot would consider Drake has ticketIDs ranging from [0 - 499] (500 tickets). The next user's ticketID would increment starting from the last one's ticketID, which means Kanye would have ticketIDs ranging from [500 - 1499] (1000 tickets).
After arranging all of the above steps, a request to Chainlink's VRF to get a random number would be made. Chainlink would then give us back a random number ranging from 0 the the max number of uint256 (Which is 115792089237316195423570985008687907853269984665640564039457584007913129639935).
For example, after sending a request to Chainlink, the service returns 9823472271002 as a random number. However, this number is too huge and is bigger than the total amount of tickets that the Epoch had. So, we would use Modulo to make sure that a user's ticketID would match the random number, which means the lucky user's ticketID would be equal to the remainder of the division of the random number, divided by the total number of tickets. So, it would be %
1002 is in Kanye's ticketID range; as such, Kanye is the lucky winner of Epoch 0.
*The above calculation is also the aspiration for the name Modulus Protocol
Last updated