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.
- 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.
-
Clone the repository:
git clone https://github.com/meitedaf/Raffle.git cd Raffle
-
Install Foundry and required dependencies:
make install
-
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>
Compile the contracts using Foundry:
```sh
forge build
```
To deploy the contracts to the Sepolia test network:
```sh
make deploy-sepolia
```
You can interact with the deployed contract using the Interactions.s.sol
script or directly through Etherscan.
This project now includes a simple frontend that allows users to interact with the raffle contract via a web interface.
-
Navigate to the
frontend
directory:cd frontend
-
Install the required dependencies:
npm install
-
Start the frontend development server:
npm start
-
Open your browser and navigate to
http://localhost:3000
to see the app.
The frontend interface will look like this:
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.
To run the tests:
```sh
forge test
```
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.