GithubHelp home page GithubHelp logo

trenddapp / lottery Goto Github PK

View Code? Open in Web Editor NEW
21.0 10.0 8.0 406 KB

Decentralized Lottery by TrendDapp ๐Ÿ’ฐ

Home Page: https://trenddapp.com/dapps/lottery

License: MIT License

Solidity 53.85% Python 46.15%
solidity brownie chainlink openzeppelin-upgrades chainlink-vrf upgradeable-smart-contract

lottery's Introduction

favicon

Trenddapp

Develop dapps for friends!

Auction . Lottery . NFT . Wordle


Lottery

A decentralized lottery app running on the Ethereum network, where you can easily participate by connecting your crypto wallet and buying tickets. After the specified lottery duration, a winner is chosen with a random number generated by Chainlink.


Building a DAPP(Decentralized Application) on Ethereum includes two major steps:

  1. Writing a smart contract and deploying it to Ethereum.
  2. Interacting with the data and smart contract on Ethereum.

Interacting with the data and smart contract on Ethereum:

No matter what programming language you are using, in order to make a request to the Ethereum network, you'll need:

Name Description
RPC Provider A node(server) that is connected to the Ethereum network, and listens to the incoming RPC requests.
Smart Contract ABI An interface that defines all methods with arguments available in the smart contract.
Smart Contract Address An address that is used to find the smart contract runner nodes in the Ethereum network.
User's Private Key A private key that is used to sign/verify the write requests(transactions).

Conventions

Here is a list of conventions used:

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

MIT

lottery's People

Contributors

dependabot[bot] avatar mobinhajizadeh avatar parsrc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lottery's Issues

invalid prizePool value for historical lotteries

I think the problem is in the claimReward function that calls _transferPrize function. In the _transferPrize function, the _winnerPrize is reduced from prizePool and then it's added to the historical lotteries.

    function claimReward()
        external
        ifCompleted
        randomNumberGenerated
        onlyWinnerOrOwner
    {
        uint256 winnerPrize = prizePool * (winnerPercentage / 100);
        _transferPrize(winnerPrize);
        _addLottery();
        _reset();
        emit ClaimedReward(lotteryID);
    }

    function _transferPrize(uint256 _winnerPrize) private {
        prizePool -= _winnerPrize;
        winner.transfer(_winnerPrize); // transfer the winnerPrize to the winner
        payable(owner()).transfer(prizePool); // transfer the rest of the prizePool to the owner
    }

    function _addLottery() private {
        allLotteries[lotteryID++] = LotteryInfo(
            lotteryID,
            prizePool,
            costPerTicket,
            startingTimestamp,
            closingTimestamp,
            winner,
            randomResult
        );
    }

And please make the startingTimestamp, winnerPercentage and lotteryDuration public :D

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.