A raffle module for the Follow and Collect actions of the Lens protocol
We want to make such routine actions as following Lens profiles or collecting posts more fun and engaging, and present a new tool for growing audience on Lens. The Lens protocol allows a custom logic to be inserted into Follow and Collect modules - this is something that wasn't available before Web3, and we want to take advantage of this.
Our product allows launching raffles for those who follow a user or collect a post.
The project demonstrates only on-follow functionality, though the code can be plugged into the collects as well.
First, a user creates a raffle and defines its parameters:
The raffle end as soon as either Duration time or Winners number is reached, whatever happens first.
After a raffle has been started, users can see its progress and conditions on the dashboard.
In this demo users have to follow through the app, because the module is not whitelisted by Lens yet.
When the raffle ends, we trigger its execution manually on the dashboard.
Determining winners We request random numbers from our contract via Chainlink and determine winners using this numbers. After determining a winner, we double-check their eligibility to enter the raffle: a winner must not be participating in the previous follow raffles of the owner and must not tamper with follow/unfollow to trick the system. The rewards are distributed by airdropping after we find all eligible winners. If there are not enough participants e.g. Max participants = 3, Prize fund = 1 MATIC, Participants = 2, then both winners receive equal share of the prize, 0.5 MATIC in this case.
To add another content discovery option for the Lens users, we list all happening raffles on the Explore page of the product.
Lens SDK, GraphQL - the Lens Protocol is the main network, providing decentralized social graph and API for this project; Chainlink for generating random number in the smart contract; Polygon as the base network; Solidity for the samrt contract; Node.js for the server part; Vue.js for the client part; MongoDB as the data storage; The Express framework.