Welcome to the official repository for blocklottery.net, a production-grade, highly scalable, and secure decentralized lottery ecosystem deployed on the Base Mainnet.
The system utilizes an advanced multi-contract architecture, separating core business logic (Factory/Child Pattern) from the data presentation layer (Renderer Pattern) to maximize gas efficiency and optimize frontend performance.
The ecosystem is split into two major layers:
┌────────────────────────────────────────────────────────┐ │ Frontend (DApp UI) │ └───────────────────────────┬────────────────────────────┘ │ Reads Rendered Data / Visuals ▼ ┌──────────────────────────────────────────────────────────────────────────────┐ │ BlockLotteryRenderer (0xEFacB328e28287e11D38f94a838C2A285143A8b9) │ ├──────────────────────────────────────────────────────────────────────────────┤ │ 📝 Formats, aggregates & renders on-chain data/views │ └───────────────────────────┬──────────────────────────────────────────────────┘ │ Queries State & Historical Data ▼ ┌────────────────────────────────────────────────────────────────────────────┐ │ BlockLotteryFactory (0x8454a5aF29f8cD981881Be6960F4bddb4Bd4cf5b)│ ├────────────────────────────────────────────────────────────────────────────┤ │ 🏭 Spawns & controls individual BlockLottery contracts │ └───────────────────────────┬────────────────────────────────────────────────┘ │ Deploys / Manages Instances ▼ ┌────────────────────────────────────────────────────────┐ │ BlockLottery Instance (Child) │ ├────────────────────────────────────────────────────────┤ │ 🎟️ Handles ticket sales, verification, and payouts │ └────────────────────────────────────────────────────────┘
- Factory Contract: Acts as the central registry and deployer. It spawns independent, isolated
BlockLotterygame instances dynamically. - Customization: Every lottery instance can be customized with dynamic ticket pricing, specific token pools, custom end-times, and reward distributions.
- Cryptographic Security: Integrates OpenZeppelin's
ECDSAlibrary. This ensures that user entries, state transitions, or winner selections are validated using secure, off-chain admin signatures to prevent front-running and exploit vectors.
- On-Chain Rendering: Decoupled from the main logic contract to save deployment and execution gas.
- Data Aggregation: Aggregates multi-contract states, user ticket history, and pool statistics into optimized view functions, significantly reducing RPC node overhead for the web interface.
- Scalability: Allows the look, metadata structure, or frontend data delivery mechanism to be updated or upgraded without altering the immutable historical lottery data.
| Contract Name | Purpose | Contract Address |
|---|---|---|
| BlockLotteryFactory | Logic Layer / Game Spawner | 0x8454a5aF29f8cD981881Be6960F4bddb4Bd4cf5b |
| BlockLotteryRenderer | Presentation Layer / Data Lens | 0xEFacB328e28287e11D38f94a838C2A285143A8b9 |
- Language: Solidity
0.8.19 - Framework Compatibility: Hardhat / Foundry / Remix IDE
- Dependencies: OpenZeppelin Contracts (Access Control, Cryptography/ECDSA, Enumerable Maps)
- EVM Target: Base / Paris (Compatible with 0.8.19 compilation targets)
- Zero-Trust Admin Validation: Uses cryptographic signature verification to approve operations.
- Gas-Optimized Loops: Uses
EnumerableSetto keep track of generated lotteries safely without hitting gas block limits. - Decoupled Architecture: Separation of Concerns (SoC) between state modification and data rendering.
Both codebases are fully flattened and verified on Blockscout. They contain all required inline dependencies (OpenZeppelin libraries) and can be easily loaded into any IDE.
- Copy the source code from the verified explorer tabs into your local files (e.g.,
BlockLotteryFactory.solandBlockLotteryRenderer.sol). - Set the compiler version to
0.8.19+commit.7dd6d404. - Enable optimization if matching production deployment metrics.
This ecosystem is open-source and licensed under the MIT License.