What it does 🍀

Tetrad Lottery is a lottery that has three specific improvements from traditional blockchain lotteries, being,

a.) using CCIP, so the lottery prizes are shared across many chains, b.) having prizes that carry through to subsequent rounds in the same brackets, c.) and being more permissionless, not needing an owner or administrator to start and end rounds.

It uses VRF v2.5 (on Arbitrum) to generate random numbers and CCIP to send transactions and funds to and from Arbitrum. Users call buyTickets() (through buyTicketsWithEther(), buyTicketsWithWETH() and buyTickets() on OP/ETH) and claimTickets() on any chain (see video.)

drawLottery() can be called by anyone, which calls generate() on the RandomNumberGenerator contract (beta), which sends a transaction to the VRF coordinator, which calls fulfillRandomWords() on the RandomNumberGenerator contract and then calls makeLotteryClaimable() on the Lottery contract, updating the final lottery numbers (see video.)

How we built it 🏭

The contracts inspired by the base logic of PancakeSwap lottery and built in solidity. There are six brackets, each with a number 0-9. Each bracket has separate rewards (defined by rewardsBreakdown), which will be adjusted over time based on the factors of amount of winners per bracket and buildup of prizes. As of this moment prizes are distributed at the rates of 1 - 15%, 2 - 17.5%, 3 20.0%, 4 - 22.5%, 5 - 10% 6 - 15%. Prizes that are not earned within a round will be passed onto the next round into its respective bracket, building up prizes in the higher brackets (see video.)

I built the frontend using Next.js and Wagmi, but I am not very good at frontend so it doesn't look to good and is pretty minimal and slightly incomplete. The frontend will be updated over the coming days. The repository is attached.

Challenges we ran into 👷🏻‍♂️

I was having trouble with CCIP and VRF because it was my first time using them, but the documentation was very helpful. I am not very good at frontend so it was fun to try out so many things I haven't used before, such as the ticket input, making a fluid and good looking experience with entering the ticket numbers.

I could not pronounce "interoperability" for my life in the video, so I'm glad I learned that!

Accomplishments that we're proud of 🥇

I am proud of getting CCIP to work, as it is such a new and innovative technology in the blockchain space. Although a lottery may be one of the simplest "games" possible, I feel this fully encompasses the usage of VRF, CCIP, while sticking to the permissionless fundamentals of blockchain and improving logic to make a more enticing lottery.

What's next for Tetrad Lottery 🤔

Tetrad Lottery is in a beta stage now, but soon contracts will be perfected and will be deployed onchain in replacement of the current contracts. The UI is very minimal allowing the purchase of tickets, and the viewing of rounds.

Development Info (for tech people) 💻

The links to the contracts + interface are attached along with a website, which will continue to be updated and a domain will be bought shortly. The website is built with Next.js, Wagmi, ConnectKit, and deployed with Cloudflare. The contacts use Chainlink (as you may have guessed) and a bit of OpenZepplin.

💙 Arbitrum One Mainnet RNG CA (VRF v2.5): 0xcc9619ae53aecac986383c4792d7ecc499dd6ecf - Verified ✅

💙 Arbitrum One Mainnet Lottery CA (CCIP Sender + Receiver): 0x415b6b93bcbb308f199702dff0a3617959c4b73a - Verified ✅

💖 Optimism Mainnet Lottery CA (CCIP Sender): 0x5746a1ec97d91c594e6042a7a42c8285c4c3a0ee - Verified ✅

💖 OP Mainnet -> 💙 Arbitrum One CCIP TX (buyTicketsWithEther) 0x686762dc3b227bd1cb49d77e63b1847a30c66450f6ad9ec9c5eba8cd89467554 - Success ✅ 🎉

🔗 VRF v2.5 ID 51011432762356398093905730634416403276871460652148190328443533066028107490533

Built With

Share this project:

Updates