A Raffle System

Raffle Cards

Designed & developed a cross chain raffle system for ERC-721 tokens, that facilitated over 100k ticket purchases.

Whoopdoop Labs • 2023

Whoopsie Doopsies is a collection with a total volume of over 800 ETH. As part of their 2023 Roadmap, they planned to develop a Raffle System similar to the one that Metawin.com has been dominating with, in the space for years. My task was to develop a system that automates the management of raffles while minimizing network costs and providing the same level of utility as the competitor.

THE PROBLEM

Metawin.com utilizes on-chain random number generation through ChainLink Upkeep, which incurs significant network fees and increases operational costs per raffle.

THE VISION

Using an automated off-chain service that initiates a process for each raffle and closes it at the designated time and provides the Smart Contract an off-chain but cryptographically secure random seed. Moreover, dropping the gas costs even further to a single penny by maximizing utilization of an L2 chain.

Breakdown

Smart Contracts

A Smart Contract logs the current discount qualifiers by tracking the wallets that hold certain NFTs on the mainnet. A few more contracts are responsible for token bridging & NFT Wrapping/Unwrapping. For the Raffle Contract, the admin wallets have the right to start and close raffles. Starting a raffle requires various parameters while closing a raffle requires a random seed. When users purchase an entry, the contract stores the number of entries bought as ranges (represented by lower and upper bounds) along with the buyer's address in an array.

Smart Contract Code

Smart Contract Snippet

WINNER SELECTION

Upon invoking the close raffle function, a cryptographically secure random number is generated and used as a seed to determine the winning entry. The winning entry can be found in the entry record using a simple binary search. This mechanism ensures scalability with a Big O complexity of O(log n) and keeps gas fees low.

Managing Raffles

Raffles can be managed through a private Discord bot. Upon a request to start a raffle, the Discord bot promptly sends a transaction and includes all the necessary parameters provided with the command. Once the designated time frame for the raffle has elapsed, the Discord bot automatically triggers another transaction to close the ongoing raffle. Moreover, the Discord bot offers a range of additional commands that allow the admin to inquire about ongoing or ended raffles, as well as check the status of a specific raffle.

Discord Command to start a Raffle

Discord Bot to Manage Raffles

Web Interface

The web features a beautiful user interface that allows users to seamlessly interact with the contracts, while also providing many other off-chain quality-of-life features. The site provides a complete ecosystem of features for the project. For instance, Claiming Royalties, Claiming V2 NFTs or essential bridging actions.

Connect Wallet Widget

Connect Wallet Widget

Raffle Detail Page

Raffle Details/Purchase Page

A Labeled Raffle Card of an Ongoing Raffle

Raffle in "Ongoing" State

A Labeled Raffle Card of an Ended Raffle

Raffle in "Ended" State

Unwrap widget to bridge NFTs to the mainnet

Asset Bridge Widget

Asset bridging widget from Eth mainnet to Nova

Unwrap Widget

User Suggestions & Features

The community has been very supportive of the project and has provided valuable feedback. Many of the features were continually developed in an agile manner based upon users feedback. For instance, during the initial release, users expressed concerns about the additional gas costs associated with ERC-20 based raffles. To purchase an entry, users had to perform two separate transactions: one to allow ERC-20 spending to the contract and another to interact with the Raffle Contract. To address this issue, I implemented a central widget that enables users to grant an allowance to the Raffle Contract. This improvement eliminates the need for users to repeatedly grant allowances if sufficient allowance has already been provided. This was later updated to ERC-2612 permit extension for ERC 20. In later updates, the widget provides utility of displaying the user's balance of Eth & ERC 20 on both chains.

ERC-20 Allowance Widget

ERC-20 Allowance Widget

Summary

The system paired with the user-friendly web interface contributed to a seamless and enjoyable user experience. With few trials, errors & especially with the user feedback, the system was driven in the right direction that it is now. The overwhelmingly positive feedback from the community validates the system's effectiveness and value.

System Map

System Map

Community Feedback

The feedback received for the current system has been overwhelmingly positive. Moreover, the system effectively provides raffles with a comparable level of utility to other competitors. While also minimizing operational costs to a significant extent, resulting in a highly cost-efficient solution.

Why has @WDoopsies always been my "home" project in Web3? The art is amazing, the community is FCKNphenomenal and the team takes feedback from the community and actually implements it, like right away! Appreciate you @otherguydoteth @KevLarLar1 and @JeBroniLames #whoopwhoop

otherguy ⚡
otherguy ⚡
@otherguydoteth

Another important update for @WDoopsies community We have heard a lot of feedback in regards to rewards claiming process ( special thanks to my guy @LazThe01 ) and applied suggestions accordingly. Every holder now able to claim ALL REWARDS ( OG AND EA) in one place. EAs can now…

Image
Image
Image
10
Reply