ChainLotto is a tiny, easy-to-read Solidity project that demonstrates how to:
and reset the game for the next round.
The goal is educational: to show core Solidity patterns (storage, payable functions, events, modifiers) in a compact, readable contract.
Empower developers to learn secure, practical Solidity patterns by providing a minimal, transparent, and modifiable on-chain lottery example. ChainLotto’s mission is to:
Educate — make core smart-contract concepts (payable functions, storage, modifiers, events, safe transfers) easy to understand through a single, focused example.
Demonstrate trade-offs — clearly show the difference between an educational implementation and production-ready systems (especially around randomness and economic attack vectors).
Encourage iteration — provide a launching pad for improvements (Chainlink VRF integration, multi-ticket purchases, front-end, automated draws) so learners can safely progress from toy examples to robust deployments.
Building and experimenting with on-chain games like lotteries is hard for beginners. Existing examples are often either overly complex or skip core Solidity fundamentals, and many tutorials gloss over important security pitfalls (like insecure on-chain randomness). New learners need a minimal, readable, hands-on example that demonstrates how to accept payments, store participants, run a draw, and handle transfers — while clearly calling out what not to do in production.
ChainLotto is a compact, beginner-friendly Solidity contract and repository that solves this by providing a complete, easy-to-follow on-chain lottery example:
A clear, well-documented smart contract (ChainLotto.sol) that implements:
a payable enter() that accepts a fixed entryFee,
on-chain storage of participants and helper view functions (getPlayers, last winner/prize/timestamp),
an owner-only pickWinner() that selects and pays a winner (with explicit notes that the randomness is insecure),
safe transfer pattern using call return checks, events for off-chain tracking, and owner utilities (setEntryFee, withdraw).
A step-by-step Quick Start (Remix + MetaMask) so learners can deploy and test immediately.
Transparent security guidance (explicitly warns about block-based pseudo-randomness and recommends Chainlink VRF for production) and suggested test cases and improvements to encourage experimentation and best practices.