project screenshot 1
project screenshot 2
project screenshot 3

Bridge Lottery

BridgeLottery is an open-source project that allows bridge owners to implement a lottery in just a few minutes.

Bridge Lottery

Created At

Superhack

Winner of

🏊 Mode — Prize Pool

Project Description

Firstly, the Bridgelottery script listens for transactions on the bridge defined in the config.json file as the eventAddress for the time defined in the subscriptionDurationInSeconds variable. A smart contract called depositor.sol is deployed in parallel and each address of users who have used the bridge are mapped inside.

When subscriptionDurationInSeconds is over, the script then call the smart contract called randomNumber.sol using Chainlink to obtain a random number and selects the winner using this formula: randomNumberGeneratedFromChainlink % numberOfParticipants. => The winner is then the address in the array corresponding to the result.

Finally, in the following example, the winner receives an attestation from EAS certifying that he has won the lottery, with a timestamp indicating the date of the win. As the prize for the lottery, the winner also receives an NFT on Zora Goerli chain.

How it's Made

We have built this project by doing a nodejs script that listen txs on the bridge, 2 smart contracts, one for the mapping of each participant and the other to get a random number from Chainlink. We also deployed 2 live examples by clonning the frontend of Optimism Bridge and Mode Bridge.

Sponsors that we are using :

  • Chainlink to get a random number.
  • EAS to send an attestation to the winner.
  • Zora to reward an NFT.
  • OP Bridge as exemple.
  • Mode Bridge as exemple.
  • TheGraph to index tx.
background image mobile

Join the mailing list

Get the latest news and updates