This project is part of the Cyfrin Updraft Foundry Fundamentals course, demonstrating the implementation of a decentralized lottery system using Solidity and Foundry.
A decentralized lottery system where participants can enter by paying an entrance fee. The lottery is managed by a smart contract that randomly selects a winner and transfers the accumulated prize pool to them.
- Foundry: A blazing fast, portable, and modular toolkit for Ethereum application development
- Forge: Testing framework
- Cast: Command-line tool for interacting with EVM smart contracts
- Anvil: Local Ethereum node
- Solidity: Smart contract programming language
- Chainlink: For price feeds and VRF (Verifiable Random Function)
- Solmate: For efficient and secure smart contract implementations
├── src/ # Source files containing smart contracts
├── test/ # Test files for smart contracts
├── script/ # Deployment and interaction scripts
├── lib/ # External dependencies
│ ├── chainlink-brownie-contracts/ # Chainlink contracts
│ └── solmate/ # Solmate contracts
├── documentation/ # Project documentation
├── broadcast/ # Deployment transaction data
├── cache/ # Foundry cache
├── out/ # Compiled contracts
├── .github/ # GitHub configuration
├── foundry.toml # Foundry configuration
└── Makefile # Build automation
- Foundry
- Git
- Clone the repository:
git clone <repository-url>
cd foundry-smart-contract-lottery- Install dependencies:
forge installforge buildforge test- Set up your environment variables in
.env:
PRIVATE_KEY=your_private_key
RPC_URL=your_rpc_url
- Deploy the contract:
forge script script/DeployLottery.s.sol:DeployLotteryScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast- Decentralized lottery system
- Chainlink VRF for secure random number generation
- Price feed integration for ETH/USD conversion
- Automated winner selection
- Prize pool management
The project includes comprehensive tests covering:
- Contract deployment
- Lottery entry functionality
- Winner selection
- Prize distribution
- Edge cases and error conditions
Run the tests with:
forge testThis project is part of the Cyfrin Updraft Foundry Fundamentals course.