Skip to content

Divyanshu-20/Blockchain-SmartContractLottery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Contract Lottery

This project is a decentralized lottery application built on the Ethereum blockchain. It uses Chainlink VRF (Verifiable Random Function) to ensure provably fair and random winner selection. The contract is written in Solidity and developed using the Foundry framework.

Overview

The Raffle.sol smart contract allows users to enter a lottery by paying a specified entrance fee. The lottery remains open for a configurable interval, and once the interval has passed and there is at least one player, a random winner is chosen. The winner receives the entire prize pool.

Key Features

  • Decentralized and Transparent: All lottery operations are handled by the smart contract, ensuring transparency and fairness.
  • Provably Fair Randomness: Chainlink VRF is used to generate a random number for winner selection, which is verifiable on-chain.
  • Automated Winner Selection: Chainlink Keepers are used to automatically trigger the winner selection process when the lottery period ends.
  • Configurable: The entrance fee, lottery interval, and other parameters can be configured during deployment.

Getting Started

Prerequisites

  • Foundry: A blazing fast, portable, and modular toolkit for Ethereum application development.
  • Git: A distributed version control system.
  • A .env file with the following environment variables:
    • SEPOLIA_RPC_URL: Your RPC URL for the Sepolia testnet.
    • PRIVATE_KEY: Your private key for deployment and interaction.
    • ETHERSCAN_API_KEY: Your Etherscan API key for contract verification.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/smart-contract-lottery-app.git
    cd smart-contract-lottery-app
  2. Install dependencies:

    make install

Usage

This project uses a Makefile to simplify common tasks. You can view all available commands by running make help.

Testing

  • Run unit tests:

    make test
  • Run forked tests on Sepolia:

    make test-fork

Deployment

To deploy the Raffle contract to a network, use the deploy command. You will need to have your .env file configured with the appropriate RPC URL, private key, and Etherscan API key.

make deploy ARGS="--network sepolia"

Interacting with the Contract

Once the contract is deployed, you can interact with it using the following commands:

  • Create a VRF subscription:

    make createSubscription ARGS="--network sepolia"
  • Add a consumer to the subscription:

    make addConsumer ARGS="--network sepolia"
  • Fund the subscription:

    make fund ARGS="--network sepolia"

Configuration

The following environment variables are required for deployment and interaction with the contract on a live network. You should create a .env file in the root of the project and add the following:

SEPOLIA_RPC_URL=your_sepolia_rpc_url
PRIVATE_KEY=your_private_key
ETHERSCAN_API_KEY=your_etherscan_api_key

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors