An open API service indexing awesome lists of open source software.

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.

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 mechanism

2. **Helper Configuration**
- Network-specific configurations
- Automated mock deployment for local testing
- Dynamic chain ID detection

3. **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 tracking

2. **Drawing Phase**
- Automated trigger based on time interval
- Chainlink VRF request for random number
- Winner selection using verifiable randomness

3. **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.