How LottoPGF Works
A High-Level Peek Under the Hood
Consider this your tl;dr. Here are just some of the features included in LottoPGF’s permissionless integration:
Out-of-the-Box Protocol
Making permissionless capital formation mechanisms not just available but accessible means lowering the barriers to using the underlying tech. Our goal is that anyone, with at least a basic background in web3 development, should be able to smoothly implement their own LottoPGF integrations. Our 'LooteryFactory' contract provides a set of configurable parameters, allowing even the most redacted novice developers among us to tailor the implementation to specific requirements, with ease.
Number Lotteries
LottoPGF V1 lotteries are "number lotteries" in which the user picks their numbers for their tickets or get them randomly assigned.
The lottery creator will determine the amount of numbers to pick (e.g. 4) and the maximum number that can be picked (e.g. 10). This will also determine the odds of the lottery (e.g. 1 in 210)!
At the end of every draw period, a set of numbers is generated and if someone picked those numbers they receive the whole prize pool. If more people picked the same number, the prize pool is split equally.
Running a Lottery
LottoPGF v1 offers a range of customization options for lottery organizers. Organizers can adjust various parameters such as the lottery name, ticket NFT symbol, the amount and range of numbers to be picked (e.g. 6 out of 69). Additionally, organizers can set the duration of each round, ticket pricing, and the distribution of ticket revenue between the cause's fund and the prize pool. The lottery can utilize any ERC-20 token, allowing flexibility in ticket purchases and prize distribution.
At the end of each lottery round the draw can be executed permissionlessly by triggering a verifiable randomness function that executes the draw logic, making it effectively impossible to manipulate the outcome. For organizers looking to conclude the lottery or run a single-round event, the "redistribution mode" or "apocalypse mode" can be activated. This mode designates the current round as the final one, and if no winning number is drawn, all tickets can be claimed for an equal share of the prize pool, effectively providing a partial refund, excluding the donated portion.
✨Black Magic✨ Algorithms: Introducing the Stateless Shuffle
Replicating conventional lotteries, like Powerball, onchain, is notoriously inefficient and gas intensive. To get around these issues, our team went to the bleeding edge in cryptography to uncover lesser-known algorithms. With Stateless Shuffle implemented, LottoPGF's integration reduces complexity, thereby keeping gas costs in check - for players and operators alike.
State-of-the-Art VRFs
LottoPGF currently runs on an EVM-compatible drand, enabling you to build trust and scale fundraising efforts through decentralised, permissionless and verifiably fair draws. But we’re not stopping here. Our end goal is to bring Verifiable Delay Functions (VDFs) onchain too.
A slightly deeper dive into the tech stack
For those of you who like a bit of context…
LottoPGF’s tech stack is comprised of two main components:
- A source of publicly verifiable randomness.
- A lottery drawing logic (aka how the winning numbers are picked).
LottoPGF’s source of publicly verifiable randomness.
✅ EVM-compatible drand (Phase 1): Verifiable Randomness Functions (VRFs) are currently our best source for cryptographically generated random numbers. Accepting the current inevitable trade-off inherent in VRFs (you can pick from publicly verifiable, censorship-resistant or trustless, but you can’t have all three), LottoPGF has opted to run on drand. Which first meant implementing the EVM-compatible BN254 curve to replace the pre-existing BLS12-381 curve it had previously been operating on .
⬜ Threshold VRF (Phase 2): To improve liveness guarantees compared to incumbent VRF solutions, we’re working towards deployment on a permissionless threshold VRF network.
⬜ VDF (Phase 3): The trilemma-killing mic drop of cryptographically verifiable randomness. The Ethereum Foundation, Protocol Labs and Supranational have made significant strides towards making VDFs accessible for practical use through their VDF ASIC project, together with recent advances in SNARKs. We are actively collaborating with Justin Drake (Ethereum Foundation) to make these viable for use on the EVM, and will implement this as a method for verifiable randomness as soon as it’s available.
LottoPGF’s lottery drawing logic (aka how the winning numbers are picked).
Executing drawing logic on Ethereum has historically been wildly inefficient.
Tired: Fisher-Yates. Commonly used, it relies on multiple storage operations and maintaining state in order to sequentially run through numbers.
Wired: Stateless Shuffles. Our discovery from the depths of advanced cryptography, it instantly shuffles lists in O(1)* by bijectively (one-to-one) mapping the original index to a shuffled index.
…In other words, the algorithm implemented in the LottoPGF integration allows us to lazily interact with a shuffled list that contains no duplications.
*not exactly but basically.