Skip to content

a lottery on blockchain, based on Chainlink VRF (Verifiable Random Function)

Notifications You must be signed in to change notification settings

meitedaf/Raffle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Provably Random Raffle Contracts

This project implements a Raffle smart contract using Solidity and Foundry. The Raffle contract allows users to enter a raffle by sending a specified amount of ether. A Chainlink VRF (Verifiable Random Function) is used to randomly select a winner.

Table of Contents

Features

  • Users can enter the raffle by sending a fixed amount of ether.
  • Uses Chainlink VRF to randomly select a winner.
  • Winner is awarded the entire balance of the contract.
  • Supports automation via Chainlink Keepers.

Installation

  1. Clone the repository:

    git clone https://github.com/meitedaf/Raffle.git
    cd Raffle
  2. Install Foundry and required dependencies:

    make install
  3. Set up your environment variables in a .env file:

    SEPOLIA_RPC_URL=<your-sepolia-rpc-url>
    PRIVATE_KEY=<your-private-key>
    ETHERSCAN_API_KEY=<your-etherscan-api-key>
    

Usage

Compile the Contracts

Compile the contracts using Foundry:

```sh
forge build
```

Deploy the Contracts

To deploy the contracts to the Sepolia test network:

```sh
make deploy-sepolia
```

Interact with the Contracts

You can interact with the deployed contract using the Interactions.s.sol script or directly through Etherscan.

Frontend Setup

This project now includes a simple frontend that allows users to interact with the raffle contract via a web interface.

  1. Navigate to the frontend directory:

    cd frontend
  2. Install the required dependencies:

    npm install
  3. Start the frontend development server:

    npm start
  4. Open your browser and navigate to http://localhost:3000 to see the app.

The frontend interface will look like this:

截屏2024-08-25 18 56 41

This frontend allows users to:

  • Connect their Ethereum wallet.
  • View the entrance fee, contract balance, recent winner, raffle state, and current players.
  • Enter the raffle by clicking the "Enter Raffle" button.

Testing

To run the tests:

```sh
forge test
```

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes and commit them (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

About

a lottery on blockchain, based on Chainlink VRF (Verifiable Random Function)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published