https://github.com/squilliamx/smart-contract-lottery-2024
A secure, decentralized raffle system built with Solidity and Foundry. Features Chainlink VRF for verifiable randomness and Chainlink Automation for trustless execution. Includes comprehensive unit tests, automated deployments, and cross-chain compatibility. Built with gas optimization and security best practices in mind.
https://github.com/squilliamx/smart-contract-lottery-2024
chainlink-automation chainlink-vrf defi foundry lottery-game smart-contracts web3
Last synced: 3 months ago
JSON representation
A secure, decentralized raffle system built with Solidity and Foundry. Features Chainlink VRF for verifiable randomness and Chainlink Automation for trustless execution. Includes comprehensive unit tests, automated deployments, and cross-chain compatibility. Built with gas optimization and security best practices in mind.
- Host: GitHub
- URL: https://github.com/squilliamx/smart-contract-lottery-2024
- Owner: SquilliamX
- Created: 2023-08-16T03:11:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-26T05:06:20.000Z (5 months ago)
- Last Synced: 2025-01-20T07:17:53.555Z (5 months ago)
- Topics: chainlink-automation, chainlink-vrf, defi, foundry, lottery-game, smart-contracts, web3
- Language: Solidity
- Homepage:
- Size: 254 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ฐ Provably Random Smart Contract Raffle
A cutting-edge, decentralized and automated raffle system built on blockchain technology, leveraging Chainlink VRF for verifiable randomness and Chainlink Automation for trustless execution.
## ๐ Features
- **Decentralized Random Selection**: Utilizes Chainlink VRF (Verifiable Random Function) v2.5 for cryptographically proven fair winner selection
- **Automated Execution**: Implements Chainlink Automation for time-based trigger mechanisms
- **Gas Optimized**: Implements custom errors and efficient storage practices for minimal gas consumption
- **Fully Tested**: Comprehensive unit tests with 100% coverage, including:
- Local blockchain testing
- Forked testnet testing
- Mainnet fork testing
- **Modular Architecture**: Clean separation of concerns between core logic, deployment, and configuration## ๐ง Technical Stack
- **Smart Contract**: Solidity 0.8.19
- **Development Framework**: Foundry
- **External Dependencies**:
- Chainlink VRF V2.5
- Chainlink Automation
- OpenZeppelin Contracts## ๐ Architecture
### Core Components
1. **Raffle Contract**
- Manages ticket purchases
- Handles winner selection
- Distributes prizes
- Integrates with Chainlink VRF for randomness
- Implements automated drawing mechanism2. **Helper Configuration**
- Network-specific configurations
- Automated mock deployment for local testing
- Dynamic chain ID detection3. **Deployment System**
- Automated deployment scripts
- Environment-specific configurations
- Subscription management for Chainlink VRF## ๐ Workflow
1. **Entry Phase**
- Users enter by purchasing tickets
- Entry fees are securely stored in the contract
- Events are emitted for front-end tracking2. **Drawing Phase**
- Automated trigger based on time interval
- Chainlink VRF request for random number
- Winner selection using verifiable randomness3. **Prize Distribution**
- Automated transfer to winner
- State reset for next round
- Event emission for transparency## ๐ก Security Features
- Comprehensive input validation
- State machine implementation
- Gas optimization techniques## ๐งช Testing
Extensive testing suite including:
- Unit tests for all core functionalities
- Fuzz testing for edge cases
- Gas optimization tests
- Network forking tests### Quick Start
```
make install
```### Run Tests
```
forge test
```## ๐ License
This project is licensed under the MIT License.
---
Built with โค๏ธ by Squilliam - Bringing transparency and fairness to decentralized raffles.