project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4

4Draw

4Draw is a decentralized lottery game featuring a smart contract for transparent operations, a user-friendly UI for ticket purchases and prize claims, and integration with Pragma’s VRF contract to ensure fairness.

4Draw

Created At

StarkHack

Project Description

Web 3 is often seemingly daunting and inaccessible to the average person. As a way to bridge this gap, we're introducing 4Draw, a decentralized lottery platform that brings a familiar concept to the blockchain world. 4Draw aims to provide a similar, approachable experience in the digital realm.

4Draw is a decentralized lottery platform inspired by the popular Numbers 4 game in Japan. The system comprises a smart contract that automates the entire lottery process, including game cycles, ticket purchases, and prize distributions. Players can choose four digits and select from multiple betting options such as Straight, Box, Set, and Mini bets.

How to Play:

  • Players choose 4 digits from 0 to 9. Digits can be repeated.
  • Players select a betting type: Straight, Box, Set, or Mini.

The betting types are:

  • Straight: The 4 numbers chosen must match the draw results exactly in the same order.
  • Box: The 4 numbers chosen must match the 4 digits drawn, but in any order.
  • Set: A combination of the Straight and Box bets.
  • Mini: The last 3 numbers chosen must match the last 3 digits drawn.

Key features of 4Draw include:

  • Transparency: All lottery rounds, ticket purchases, and prize distributions are immutably recorded on the Starknet blockchain.
  • Fairness: Integration with Pragma VRF ensures verifiably random and tamper-proof number selection.
  • Decentralization: The smart contract autonomously execute all processes, including prize distribution, without central authority control.
  • Global Accessibility: Anyone with internet access can participate from anywhere. The platform operates entirely on-chain through a smart contract deployed on Starknet. The process includes:
  • Ticket Purchases: Players connect their wallets, call the Purchase function, and send bet details and fees.
  • Random Draws: At round closure, anyone can prompt the contract to request a set of secure random numbers from Pragma's VRF contract.
  • Result Processing: The contract compares purchased combinations against the draw, calculating winners for all bet types. -Prize Distribution: Winners can claim prizes from the contract. When there are no winners, the prize amount will be compounded into the next round.

Players interact with 4Draw through a dApp interface, allowing easy number selection, ticket purchase, result viewing, and prize claiming. This structure ensures a transparent, efficient, and fair lottery experience, leveraging blockchain technology to create a trustless alternative to traditional centralized lotteries.

How it's Made

4Draw uses Cairo for smart contract development on Starknet. Cairo's features enable efficient on-chain execution of complex computations, necessary for managing the logic of our betting options (Straight, Box, Set, and Mini).

To ensure the randomness and fairness of lottery results, we utilize Pragma's Verifiable Random Function (VRF) contract, which provides a verifiable source of randomness resistant to manipulation.

Implementing different betting options required careful design of smart contract logic to handle various combinations in Box and Set bets, ensuring correct identification and rewarding of all winning scenarios. We also built an automated prize distribution mechanism directly through the smart contract, considering gas costs and Starknet's transaction model for efficient payouts.

The frontend (seen in our demo) was developed using React. We used Starknet.js to connect the frontend with the deployed smart contract allowing players to interact with the system from web browsers.

background image mobile

Join the mailing list

Get the latest news and updates