Skip to content

A decentralized raffle and lottery system built in Solidity, enabling verifiable randomness and fair winner selection on the Ethereum blockchain.

Notifications You must be signed in to change notification settings

Logic-gate-sys/raffle_lottery

Repository files navigation

Raffle Lottery

Project Motivation

The Raffle Lottery project aims to decentralize the traditional lottery system using Ethereum smart contracts. By leveraging Solidity and Chainlink integrations, the system ensures transparency, fairness, and automation in lottery operations. The core motivations include:

  • Eliminating centralized control and human error.
  • Providing trustless and automated raffle draws.
  • Offering a seamless experience for participants through a decentralized application (dApp).

This smart contract enables:

  1. Entering a raffle by paying the required entrance fee in ETH.
  2. Automated upkeep and interval management for generating random numbers using Chainlink VRF (Verifiable Random Function) and Data Feeds.
  3. Automated raffle draws using Chainlink Keepers to ensure timely and fair selection.
  4. Random winner selection at the end of each raffle.
  5. Automated prize distribution to the winner’s account via smart contracts.
  6. Continuous operation, allowing new raffles to be created once the previous one ends.

Project architecture:

              +-----------------+
              |  User Wallet    |
              +--------+--------+
                       |
                       v
              +-----------------+
              |      dApp       |
              | React + Tailwind|
              +--------+--------+
                       |
                       v
             +-------------------+
             |  Raffle Contract  |
             | Solidity (EVM)   |
             +--------+----------+
                       |
   +-------------------+------------------+
   |                                      |

+--------------+ +--------------+ | Chainlink VRF| | Chainlink | | Randomness | | Keepers | +--------------+ +--------------+

Test Suite

The project uses Foundry's standard library for comprehensive unit testing of core contract functionalities, including:

  1. Entering a raffle and validating entries.
  2. Performing upkeep and verifying interval-based operations.
  3. Testing utility functions for correctness.
  4. Simulating Chainlink automation using warp functions for time-dependent tests.

These tests ensure reliability, security, and correct behavior of the raffle system.


User Experience

Users interacting with this smart contract can expect:

  • A secure, transparent raffle experience without central authority interference.
  • Automatic random winner selection, removing any bias or manipulation.
  • Immediate and trustless distribution of prizes upon raffle completion.
  • Continuous availability of new raffles without manual intervention.

How to Interact with the Contract (via the dApp)

Users can participate in the raffle through the decentralized application (dApp) as follows:

  1. Connect Wallet: Link your Ethereum wallet (e.g., MetaMask) to the dApp.
  2. Enter Raffle: Pay the entrance fee in ETH to participate.
  3. Monitor Raffle Status: Track ongoing raffles, entry counts, and countdowns for draw time.
  4. Claim Winnings: If selected, the prize will be automatically transferred to your wallet.
  5. Participate in New Raffles: Once a raffle ends, new ones are automatically available.

The dApp abstracts the underlying smart contract operations, making it easy for users to participate without manual interaction with the blockchain.


##License

This project is licensed under the MIT License. See the LICENSE file for details.

##Contributing

We welcome contributions to improve the Raffle Lottery project! How to Contribute Fork the repository. Create a new branch for your feature or bug fix:

git checkout -b feature/my-new-feature

###Commit your changes:

git commit -m "Add new feature"

Push to your branch:

git push origin feature/my-new-feature

Open a Pull Request with a clear description of your changes.

Code Guidelines:

Follow Solidity best practices for smart contract development. Keep React components modular and reusable. Use Tailwind CSS for styling and maintain design consistency. Include tests for any new functionality.

References and Acknowledgements


About

A decentralized raffle and lottery system built in Solidity, enabling verifiable randomness and fair winner selection on the Ethereum blockchain.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published