Code Monkey home page Code Monkey logo

smart-contract-lottery's Introduction

Proveable Random Raffle Contract

Description

This contract implements a sample raffle using Chainlink VRF Version 2. Participants can enter the raffle by paying an entrance fee, and a random winner is chosen periodically.

Layout of Functions

  • Constructor
  • External
  • Public
  • Internal
  • Private
  • View & Pure Functions

Contract Details

  • Version: Solidity ^0.8.19
  • License: MIT

Imports

The contract imports necessary interfaces and libraries from the Chainlink Brownie contracts.

Errors

The contract defines custom errors for various exceptional scenarios.

Interfaces, Libraries, Contracts

The contract interfaces with VRFCoordinatorV2Interface, VRFConsumerBaseV2, and AutomationCompatibleInterface.

Type Declarations

The contract defines an enum RaffleState to represent the state of the raffle.

State Variables

  • Chainlink VRF variables
  • Lottery variables

Events

  • RequestedRaffleWinner: emitted when a random winner is requested.
  • RaffleEnter: emitted when a participant enters the raffle.
  • WinnerPicked: emitted when a winner is picked.

Functions

  • Constructor: Initializes the contract with required parameters and sets initial state.
  • enterRaffle: Allows participants to enter the raffle by paying the entrance fee.
  • checkUpkeep: Checks if the upkeep of the raffle is needed.
  • performUpkeep: Initiates Chainlink VRF call to get a random winner.
  • fulfillRandomWords: Called by Chainlink VRF node to determine the winner and distribute the prize.

Getter Functions

Provides public access to various state variables and contract parameters.

smart-contract-lottery's People

Contributors

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