Skip to content

A decentralized lottery smart contract built with Solidity and Foundry. Users enter the lottery without paying ETH, and a random winner is selected.

Notifications You must be signed in to change notification settings

StevenWilliams198318/0x03-Smart_Contract_Lottery

Repository files navigation

🎰 Smart Contract Lottery (0x03-Smart_Contract_Lottery)

A decentralized lottery smart contract built with Solidity and Foundry. Participants can enter the lottery by sending ETH, and a winner is randomly selected and rewarded with the total pool. This project is designed to demonstrate randomness, secure value transfers, and Solidity best practices.


📂 Project Structure

0x03-Smart_Contract_Lottery/ ├── lib/ # Dependencies (e.g., forge-std) ├── script/ # Deployment scripts ├── src/ # Main contract (Lottery.sol) ├── test/ # Unit tests ├── foundry.toml # Foundry configuration └── README.md

⚙️ Features

  • ✅ Players enter by sending ETH
  • ✅ Only the owner can pick the winner
  • ✅ Random winner selection (pseudo or oracle-based)
  • ✅ Transparent and auditable
  • ✅ Withdrawals handled securely

🚀 Getting Started

1. Clone the repository

git clone https://github.com/YOUR-USERNAME/0x03-Smart_Contract_Lottery.git
cd 0x03-Smart_Contract_Lottery

2. Install dependencies | Install Foundry

forge install
forge build
forge test
forge script script/Deploy.s.sol --rpc-url <YOUR_RPC_URL> --private-key <YOUR_PRIVATE_KEY> --broadcast

Foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

  • Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
  • Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
  • Chisel: Fast, utilitarian, and verbose solidity REPL.

Documentation

https://book.getfoundry.sh/

Usage

Build

$ forge build

Test!

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

About

A decentralized lottery smart contract built with Solidity and Foundry. Users enter the lottery without paying ETH, and a random winner is selected.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published