Raffle Draw Platform on Arbitrum
# Overview
This project is a decentralized raffle draw platform built on the Arbitrum Layer 2 network. It utilizes smart contracts deployed via Hardhat and integrates Chainlink VRF for fair random winner selection. The frontend is developed with React.js, allowing users to interact with the platform seamlessly by entering raffles, viewing live results, and connecting their wallets.
## Features
- **Blockchain-based**: Uses Arbitrum for lower gas fees and fast transactions.
- **Secure Randomness**: Chainlink VRF ensures fairness in winner selection.
- **User-friendly UI**: Built with React.js, providing a sleek interface.
- **Wallet Integration**: Users can connect with wallets like MetaMask to participate in raffles.
- **Responsive Design**: Optimized for both desktop and mobile devices.
## Technology Stack
- **Smart Contracts**: Written in Solidity and deployed using Hardhat on Arbitrum.
- **Frontend**: React.js framework for building a dynamic and responsive user interface.
- **Randomness Provider**: Chainlink VRF for verifiable randomness.
- **Blockchain Network**: Arbitrum Layer 2 for scalability and lower transaction costs.
## Prerequisites
- **Node.js**: Make sure you have Node.js installed. You can download it from [here](https://nodejs.org/).
- **Hardhat**: Install Hardhat by running the following command:
```bash
npm install --save-dev hardhat
```
- **Arbitrum Network Setup**: Ensure you have set up the Arbitrum network in your wallet (e.g., MetaMask).
- **Chainlink VRF**: Configure Chainlink VRF for secure and random number generation.
## Getting Started
### 1. Clone the Repository
```bash
git clone https://github.com/your-username/raffle-platform.git
cd raffle-platform
cd raffle-smart-contracts
npm install
cd raffle-frontend
npm install
├── raffle-smart-contracts # Smart contracts and Hardhat config
│ ├── contracts
│ │ └── Raffle.sol # The Raffle smart contract
│ ├── scripts
│ │ └── deploy.js # Deployment script
│ ├── test
│ │ └── raffle.test.js # Smart contract tests
│ └── hardhat.config.js # Hardhat configuration
├── raffle-frontend # React.js frontend code
│ ├── public
│ ├── src
│ │ ├── components # React components
│ │ ├── hooks # Custom hooks for blockchain interaction
│ │ └── App.js # Main entry point for the app
│ └── package.json
└── README.md
npx hardhat compile
Update your .env
file with the following:
ALCHEMY_API_URL=https://arb-rinkeby.alchemyapi.io/v2/your-api-key
PRIVATE_KEY=your-private-key
VRF_COORDINATOR=0x...
LINK_TOKEN=0x...
KEY_HASH=0x...
FEE=...
Deploy the contract to the Arbitrum test network:
npx hardhat run scripts/deploy.js --network arbitrumTestnet
Create a .env
file in the frontend directory with the following:
REACT_APP_CONTRACT_ADDRESS=your-deployed-contract-address
REACT_APP_CHAIN_ID=421611 # Arbitrum Testnet Chain ID
REACT_APP_ALCHEMY_API_KEY=your-alchemy-api-key
Start the frontend application:
npm start
- Enter a Raffle: Connect your wallet and enter an ongoing raffle by paying the entry fee.
- Random Winner Selection: After the raffle is full or the deadline has passed, the Chainlink VRF service is called to randomly select a winner.
- Claim Prize: The winner can claim their prize via the platform.
Run the smart contract tests using Hardhat:
npx hardhat test
- Frontend Deployment: Host the React frontend on a service like Vercel or Netlify.
- Smart Contract Deployment: Deploy the smart contract to the Arbitrum mainnet.
MIT