This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Etherium is a Solidity smart contract project implementing an ERC20 token backed by ETH with daily lottery mechanics and decentralized randomness generation. The token uses a 1:1 ratio (1 ETH = 1 ETHERIUM, both with 18 decimals) and implements a 1% fee structure on all operations.
forge buildforge test
# Run specific test
forge test --match-test testMintingWithFee
# Run with verbosity for debugging
forge test -vvv# Requires PRIVATE_KEY environment variable
forge script script/Deploy.s.sol --rpc-url <RPC_URL> --broadcastforge clean && forge build- Main Contract:
src/Etherium.sol- Inherits from OpenZeppelin's ERC20 and ReentrancyGuard - Fee System: 1% total fee split into 0.9% lottery pool and 0.1% randomness participant rewards
- PepeUSD Lock Mechanism:
- Users can lock 100 PepeUSD during minting period (each lock enables one fee-free mint)
- Multiple locks allowed per user (e.g., lock 300 PepeUSD for 3 fee-free mints)
- Call
mintFeeFree()to use a lock and mint without fees - All locks unlockable after 1 month from deployment
- Holder Tracking: Uses Fenwick tree (Binary Indexed Tree) for O(log n) cumulative balance queries, enabling efficient lottery winner selection
- Randomness: Commit-reveal scheme with 24-hour cycles (12h commit, 12h reveal phases)
- Synthetic Addresses: Uses hardcoded addresses for LOTTERY_POOL and RANDOMNESS_POOL to track fee distributions
- Fenwick Tree Implementation: Maintains cumulative holder balances for efficient random selection from total supply
- Time-based Phases:
- 7-day initial minting period with unlimited supply
- After minting period: fixed max supply based on initial deposits
- Daily lottery cycles with commit-reveal randomness
- Fail-Fast Philosophy: Avoid defensive coding patterns that hide errors. Unexpected behaviors should cause explicit failures during testing, not silent handling in production
- Code Simplicity: Prioritize clarity and efficiency. Write straightforward, readable code over complex abstractions
- Storage Optimization: Apply variable packing when it reduces storage reads (SLOADs) without compromising safety. Group related variables of smaller types together to fit in single storage slots
- OpenZeppelin Contracts: ERC20 base implementation and ReentrancyGuard
- PepeUSD Token: ERC20 token at 0xed7fd16423Bc19b9143313ac5E4B7F731D714e97 for fee exemption mechanism
- Forge-std: Testing framework and utilities
Tests are located in test/ directory and use Foundry's testing framework. Key test areas:
- Minting and redemption with fee calculations
- Lottery winner selection using Fenwick tree
- Commit-reveal randomness generation
- PepeUSD locking mechanism
- Edge cases around time transitions and phase changes
- Test Debugging Priority: When tests fail, first verify the test logic is correct before assuming contract bugs. Test implementation errors are more common than contract issues
- Fenwick Tree Updates: When balances change, the contract updates the Fenwick tree to maintain cumulative sums for lottery selection
- Smart Contract Exclusion: Smart contracts are excluded from lottery participation (only EOAs can win)
- Fee Minting During Initial Period: During the 7-day minting period, fees are also minted as new tokens rather than redistributed
- Redemption Creates Capacity: After minting period ends, burning tokens creates capacity for new mints up to the original max supply