Why We’re Using Chainlink VRF as a Provably Fair Way to Draw Lottery Winners
Greetings CAKE flippers!
Following the recent launch of the PancakeSwap Lottery V2, we’re delighted to announce our mainnet integration of Chainlink Verifiable Random Function (VRF). In this post, we’ll be diving into our integration of this random number generator (RNG).
As the industry’s leading secure and auditable RNG, Chainlink VRF provides a provably fair source of randomness used to select winners in our Lottery V2 application, along with a supporting cryptographic proof that verifies the RNG process as tamper-proof. Thanks to our integration of Chainlink VRF, lottery players can rest assured that all users have an equal opportunity of winning prizes while enjoying the fun new game.
A short recap: The PancakeSwap Lottery has two draws every day. Users can participate by buying tickets, which each contain 6 digits. Prizes are determined by how many digits on the user’s ticket, starting with the first digit on the left, match the digits generated by Chainlink VRF. The breakdown is as follows:
The new lottery has already become hugely popular, with the largest prize pool to date totaling around $1.165M (77,687 CAKE) in round 16! Given the value at stake, it was very important to bring transparency and security to the winner selection process so no single party could unfairly influence the results.
However, accessing a manipulation-resistant source of randomness on-chain in a verifiable manner isn’t as straightforward as it might seem. On-chain RNG solutions like blockhashes can be subject to miner manipulation, while off-chain RNG solutions are opaque and provide no proof of integrity. Overcoming these hurdles is why we selected Chainlink VRF for the PancakeSwap Lottery V2.
On a technical level, Chainlink VRF functions by combining:
1) block data that is still unknown when the request is made, with;
2) the oracle node’s pre-committed private key.
This combination is used to generate both a random number and a cryptographic proof. The PancakeSwap Lottery V2 smart contract will only accept the random number input if it has a valid cryptographic proof, and the cryptographic proof can only be generated if the VRF process is tamper-proof. This provides users with automated and publicly verifiable assurances that each random number draw is provably fair and can’t be tampered with or predicted by the oracle, outside entities, or PancakeSwap team.
Integrating Chainlink VRF was very important to bringing undeniable fairness and transparency to our random number draws, as any user can independently audit the integrity of the RNG to verify that it’s unbiased, unpredictable, and manipulation resistant.
For other projects looking for on-chain RNG, we’re happy to say that Chainlink VRF was also very easy to integrate and backed by Chainlink’s reliable oracle infrastructure, which we also use for PancakeSwap Prediction.
Have you played the lottery yet?
Got a minute to spare?
Take our Community Survey to help us understand your thoughts about the new lottery!
Stack ‘em! (tickets, that is)