Git Product home page Git Product logo

chainlink-lottery's Introduction

Multiwin chainlink lottery collection

This project is a multi-ticket multi-winning lottery using random winning numbers from Chainlink.

The project comes with four types of lottery contracts, ERC-20 lottery loken contract used for buying tickets, ERC-721 lottery ticket contract, and two random generating contracts (the first one is for testing and the second one is for deployment in the testnet using Chainlink). Also the project has deployment scripts for each type of lottery.

For one lottery token you can purchase one lottery ticket.

Lottery types

Contract name Buying tickets rules Withdrawing the reward rules Description
OneTicketPerUserLottery.sol It's allowed to buy only one ticket per user. For each your winning ticket you will get a reward. When withdrawing a reward, a coin is tossed, taking into account your chance of winning, depending on the number of tickets purchased
OneWinPerUserLottery.sol It's allowed to buy as many tickets as there are left in the lottery,
but not more than 10 tickets at once
You can only receive a reward for only one winning ticket. After that, withdrawing the reward is blocked. Admin starts the function of generating winning tickets after all tickets were purchased. The participant can view his winning tickets by using view function of contract. After that, he can start the function of obtaining an award by indicating the number of the winning ticket.
MultiWinPerUserLottery.sol Similarly as in OneWinPerUserLottery.sol You can receive a reward for each your winning ticket,
but not more than 10 rewards at once
Similarly as OneWinPerUserLottery.sol except that when withdrawing an award, the participant can indicate more than one winning ticket.
CircularLottery.sol Similarly as in OneWinPerUserLottery.sol Similarly as in MultiWinPerUserLottery.sol After all tickets have been purchased, they are combined into a ring. If you buy tickets in a row it increases the chance of hitting the jackpot, otherwise you increase the chances of winning.

Compilation

To compile all contracts:

npx hardhat compile

Deploy

To deploy the specific lottery type smart contract to the rinkeby testnet:

npx hardhat run scripts/{lottery type}.js --network rinkeby

Tests

For checking tests you should change imports in all lottery contracts:

from: import "./Randomness.sol"; to: import "./FakeRandomness.sol";

After that you can run all tests:

npx hardhat test

chainlink-lottery's People

Contributors

catcatcat8 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.