Code Monkey home page Code Monkey logo

lottery-contract's Introduction

Lottery-Contract


Repository setup

Install

To install the needed packages run:

yarn or npm install

Build

To build the smart contracts run:

yarn build or npm run build

Test

To run the tests for the smart contracts run:

yarn test or npm run test

Test coverage

For the test converge of the contracts run:

yarn cover or npm run cover

There are multiple mock contracts that have been created for testing purposes. These have been excluded from the coverage. For more information check the .solcover.js.

Deploy

To deploy the contracts locally run:

yarn deploy:local or npm run deploy:local

Note that deploying the contracts locally does not require any inputs.

Design Notes

The Lottery and LotteryNFT contracts both inherit from a contract called Testable. This contract allows for simple time manipulation for testing purposes. For a non-local deployment the address of this contract can simply be set to 0 in the constructor and the contracts will use the current block.timestamp.

lottery-contract's People

Contributors

chefnyan avatar nicca42 avatar pancake-swap avatar

Stargazers

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

Watchers

 avatar  avatar

lottery-contract's Issues

lotteryStatus

Hey guys,
I'm new to solidity and I was looking at your code to try to understand how things work.
Anyway, isn't this test incorrect:

if(_startingTimestamp >= getCurrentTime()) {

if(_startingTimestamp >= getCurrentTime()) {
     lotteryStatus = Status.Open;
} else {
      lotteryStatus = Status.NotStarted;
}

If the starting timestamp is bigger than the current time, then the status should be NotStarted. It should be like this:

if(_startingTimestamp >= getCurrentTime()) {
     lotteryStatus = Status.NotStarted;
} else {
      lotteryStatus = Status.Open;
}

And maybe I would add a "require" to make sure that _closingTimestamp is bigger than getCurrentTime(). Because there is no point to create a lottery that is already closed.

Proposal

Can you add the option to buy fractions of lottery tickets?

Lottery Ticket Generation

After buying some tickets, I've noticed that one number of a ticket was repeated.
After checking this file: Lottery.sol

  1. Shouldn't the Buy method check and avoid repeated items on the ticket?
  2. Shouldn't the Buy method be called inside MultiBuy?

image

Thanks.

Update the lottery NFT to ERC1155

The lottery logic currently relies on a ERC721 token to handle NFT tickets.

https://bscscan.com/token/0x5e74094cd416f55179dbd0e45b1a8ed030e396a1

Owing to technical limitations (no batch minting) in the ERC721 standard, it is essential to update the lottery logic with a new LotteryNFT built under the ERC1155 standard.

The purpose of this change is to batch mint tickets, which will result in massive gas reduction for users, and allow greater participation from users.

https://docs.openzeppelin.com/contracts/3.x/erc1155

TypeError: lotteryInstance.init is not a function

Hi, I get the following error on running yarn deploy:local.

TypeError: lotteryInstance.init is not a function
    at main (/home/eth/lottery-contract/scripts/deploy.js:85:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.

Any suggestions why this is the case?

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.