GithubHelp home page GithubHelp logo

ceseshi / etherlotto Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7 KB

The "EtherLotto" contract provides a decentralized lottery system using non-fungible tokens (NFTs). Each ticket purchase results in the minting of a unique NFT, and the ticket price contributes to a cumulative prize pool.

Solidity 100.00%

etherlotto's Introduction

EtherLotto

This contract provides a decentralized lottery system using non-fungible tokens (NFTs) and Verifiable Random Functions, on the Sepolia test blockchain.

Each ticket purchase results in the minting of a unique NFT, and the ticket price contributes to a cumulative prize pool.

Key features of this contract include:

  • Ticket Purchase: Users can buy lottery tickets by sending the exact ticket price to the contract. Each purchase mints an NFT, which acts as the lottery ticket.
  • Prize Accumulation: A portion of each ticket sale contributes to the prize pool, while another portion is collected as fees for the maintenance and operation of the lottery.
  • Chainlink VRF Integration: The contract integrates Chainlink's Verifiable Random Function (VRF) to ensure fair and transparent random number generation. This randomness is used to select a winner from among the NFT holders when a lottery draw is conducted.
  • Draw Mechanism: Only the owner of the contract can initiate a draw, which requires at least three tickets to have been sold. This restriction ensures that there is a minimal level of participation for each draw.
  • Prize Distribution: When a draw occurs, the Chainlink VRF function selects a random winner based on the generated random number. The accumulated prize pool is then transferred to the winner's address.
  • Fee Withdrawal: The contract owner can withdraw the accumulated fees, which are collected from ticket sales.
  • Security Features: The contract implements several security measures, including reversion on incorrect Ether transfers and safeguarding against insufficient ticket sales and transfer failures. This contract not only offers a transparent and fair mechanism for lottery but also leverages the security and reliability of Ethereum's smart contracts and Chainlink's decentralized oracle network, bringing a high degree of trust and automation to the process.

This is just a practice, do not use in production.

How to install

forge install
forge build

ToDo

  • Foundry Tests
  • Support other networks

etherlotto's People

Contributors

ceseshi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.