A gamified way to learn blockchain and web3 concepts on EDU-chain network.
This project implements a decentralized lottery system on the Ethereum blockchain using Solidity. Participants enter the lottery by sending 0.00001 ETH, and once at least 3 players have joined, the contract owner (manager) can randomly pick a winner who receives the entire balance of the contract.
Entry Fee: Participants must send exactly 0.00001 ETH to join.
Random Winner Selection: Uses keccak256
hashing with blockchain randomness.
Secure Fund Handling: Only the contract manager can access the balance and pick a winner.
Automated Reset: The lottery resets after a winner is selected.
Smart Contract Language: Solidity (^0.5.0 < 0.9.0
)
Blockchain: Ethereum-compatible networks
Tools: Remix IDE, Hardhat, MetaMask, Ethers.js
lottery.sol
manager
→ The deployer who controls the lottery.
players
→ A dynamic array storing participants.
receive
)Players send 0.00001 ETH to enter.
The contract automatically adds them to the players
list.
If incorrect ETH is sent, the transaction fails.
pickWinner
)Can only be called by the manager.
Requires at least 3 players.
Uses a pseudo-random number to select a winner.
Transfers the entire contract balance to the winner.
Resets the players
array for a new round.
Open Remix IDE and create lottery.sol
.
Compile the contract using Solidity 0.8.x compiler.
Deploy on Ethereum Testnet (e.g., Sepolia, Goerli) or Local Hardhat Network.
Send 0.00001 ETH to the contract from MetaMask or a script.
const signer = provider.getSigner();
const tx = await signer.sendTransaction({
to: "0xYourContractAddress",
value: ethers.utils.parseEther("0.00001") // Entry fee
});
await tx.wait();
console.log("Successfully joined the lottery!");
Call pickWinner()
(only the manager can do this).
Winner receives all ETH in the contract.
The lottery resets for a new round.
The contract does not use Chainlink VRF, so randomness is not truly secure.
A miner could manipulate block.prevrandao
(previously block.difficulty
).
This should not be used for high-value lotteries on mainnet.
✅ Implement Chainlink VRF for fair randomness.
✅ Add automated winner selection after a fixed time.
✅ Support multiple rounds without requiring manual resets.
50
Yes, we are open for fundraising and need your support to make the project live.