Giter Site home page Giter Site logo

cyfrin / chainlink-lottery Goto Github PK

View Code? Open in Web Editor NEW
78.0 5.0 34.0 1.67 MB

A web3 implementation of a lottery using Chainlink VRF and Chainlink alarm clock to have a totally decentralized lottery

JavaScript 89.78% HTML 6.63% CSS 3.58%
chainlinkvrf chainlink chainlink-alarm-clock lottery decentralized

chainlink-lottery's Introduction

chainlink-lottery

You can play with this in remix here

A web3 implementation of a decentralized provably random lottery using Chainlink VRF and Chainlink alarm clock to have a totally decentralized lottery. Check the ETH readme for how to do the truffle stuff.

The front end is super broken.

If you play with it in remix, do the following:

  1. Compile all contracts and interfaces
  2. Deploy the governance contract
  3. Deploy the randomness contract with the governance contract address as a parameter
  4. Deploy the lottery contract with the governance contract address as a parameter
  5. call the governance function init with the lottery address, followed by the randomness address as parameters
  6. fund the randomness and lottery contract with some LINK
  7. Call the start_new_lottery function, with a duration you'd like it to last in seconds.
  8. Enter the lottery and have fun.
  9. After the duration is up, the winner should be automatically randomly chosen via Chainlink VRF - and the lottery will totally reset, so you can start another one.

You'll notice there are a few permission hiccups, but this is a beta so whatever.

To run:

git clone <this_repo>
cd chainlink-lottery
npm install

Make sure you have RPC_URL and MNEMONIC in your environment variables

To set this template up from scratch, you can run:

Setup:

npx create-react-app chainlink-lottery
cd chainlink-lottery
mkdir ethereum
cd ethereum
truffle unbox smartcontractkit/box

Mirgrate

truffle migrate --network live

TODO

  • Fix all the permission issues (random people can break the lottery at the moment, should be an easy fix)
  • Add more VRF nodes to decentralize the random number part
  • Add more Alarm clocks to decentralize the alarm clock part
  • Write tests
  • write scripts to make stuff easier
  • Cool frontend

chainlink-lottery's People

Contributors

patrickalphac 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

Watchers

 avatar  avatar  avatar  avatar  avatar

chainlink-lottery's Issues

Question for addresses harcoded in the code

image
image

Hello, I got here through a tutorial, looking at the topic of making a lottery in blockchain, but I have the problem that you have that addresses harcoded both in truffle and in the frontend... What is that addresses? when I run the frontend I get this error:

image

I have deployed the contracts with Rinkeby, I have seen that you have written something about Ropsten, but it is not clear to me if I have to deploy the contracts there for the project to work.

Doubt about login from contract owner

Hi, I've been looking at your code.
I ask you a question.
How would you make a general frontend where both the owner of the lottery contract and the buyers can access?
And only show a getWinner button for the owner?
I am using ethers.js
and I'm not sure how to do it.

Thanks

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.