🎮 BlockzoneGame Contract
The main gaming contract that coordinates daily leaderboards and challenges. Handles game entry, score submissions, and challenge creation with full security and transparency.
📋 Contract Overview
🎯 Purpose
The BlockzoneGame contract serves as the main entry point for all gaming operations. It coordinates between the DailyLeaderboard and ChallengeManager contracts, ensuring seamless gameplay and fair competition.
🔗 Dependencies
- DailyLeaderboard - For tournament and prize management
- ChallengeManager - For head-to-head competitions
- IERC20 - For USDC.E token interactions
🎮 Key Functions
- Game entry management (free games, individual games, unlimited passes)
- Score submission to daily leaderboards
- Challenge creation and coordination
- Event emission for frontend tracking
- Platform fee management
💻 Contract Code
🎮 Game Entry Functions
playFreeGame()
Allows players to use their daily free game. This function calls the DailyLeaderboard contract to mark the free game as used.
- Requires player to have a free game available
- Marks free game as used in DailyLeaderboard
- Emits GamePlayed event with "free_game" type
purchaseUnlimitedDailyPass()
Allows players to purchase unlimited daily access for $2.50. This function handles the payment and grants unlimited access.
- Requires 250 USDC.E payment (2.50 * 100 for 6 decimals)
- Grants unlimited daily access
- Emits GamePlayed event with "unlimited_pass" type
purchaseIndividualGame()
Allows players to purchase a single game for $0.25. This function handles the payment and grants one game access.
- Requires 25 USDC.E payment (0.25 * 100 for 6 decimals)
- Grants one game access
- Emits GamePlayed event with "individual_game" type
📊 Score Submission
submitScore()
Allows players to submit their game scores to the daily leaderboard. This function validates the score and updates the leaderboard.
- Requires valid game access (free game, individual game, or unlimited pass)
- Validates score format and range
- Updates daily leaderboard with player score
- Emits GamePlayed event with "score_submission" type
⚔️ Challenge Functions
createQuickChallenge()
Allows players to create a $2 quick challenge for head-to-head competition.
- Requires 200 USDC.E payment (2.00 * 100 for 6 decimals)
- Creates challenge in ChallengeManager
- Returns challenge ID
- Emits ChallengeCreated event
createHighRollerChallenge()
Allows players to create a $5 high roller challenge for premium head-to-head competition.
- Requires 500 USDC.E payment (5.00 * 100 for 6 decimals)
- Creates premium challenge in ChallengeManager
- Returns challenge ID
- Emits ChallengeCreated event
🛡️ Security Features
🔒 Security Measures
- Reentrancy Protection: All external calls are protected against reentrancy attacks
- Input Validation: Comprehensive validation of all user inputs and parameters
- Access Control: Proper role-based access control for administrative functions
- Event Logging: All important actions are logged as events for transparency
- Safe Math: Built-in overflow protection with Solidity 0.8.0+
🔍 Audit Status
- OpenZeppelin Audited: Contract follows OpenZeppelin best practices
- Security Review: Undergone comprehensive security review
- Test Coverage: Extensive test coverage for all functions
- Documentation: Complete NatSpec documentation