Peer2PlayGenericStakingContract
The Peer2PlayGenericStakingGames
contract provides a flexible framework for managing staking-based multiplayer games. Key features include game and match lifecycle management, customizable fee structures, and support for private and public matches. The contract ensures security, scalability, and ease of integration into decentralized ecosystems.
Imports Used & Their Significance
ReentrancyGuard
: Prevents reentrancy attacks.Ownable
: Grants admin privileges for sensitive functions.Pausable
: Enables emergency stops for games or the entire platform.SafeERC20
: Ensures secure interactions with ERC20 tokens.
State Variables
Protocol-Level Variables
matchCounter
: Ensures unique match IDs.protocolFee
: Fee percentage applied to all matches.drawFee
: Fee percentage for drawn matches.FEE_DENOMINATOR
: Denominator for basis point calculations.
Game & Match Mappings
gameUids
: Links game UIDs to their metadata.matches
: Stores match details by ID.allowedTokens
: Defines eligible ERC20 tokens and their minimum stakes.
Function Descriptions
Game Management
addGame
: Adds a new game to the platform.updateGameFee
: Allows game owners to adjust their game fee.pauseGame
: Temporarily halts a game for maintenance or issues.unpauseGame
: Resumes operations for a paused game.removeGame
: Deletes a game from the platform.
Fee & Token Management
setProtocolFee
: Sets platform-wide fees for matches.setDrawFee
: Defines fees for matches that end in a draw.allowToken
: Adds or updates eligible staking tokens.
Match Lifecycle
createMatch
: Initializes a new match with customizable parameters.joinMatch
: Enables players to join matches, verifying authorization for private matches.submitMatchResult
: Submits results and distributes rewards or refunds.cancelMatch
: Cancels a match and refunds participants.
Internal Utilities
_handleDraw
: Handles refunds for drawn matches._amountAfterCut
: Computes net amount after deducting fees._transferFunds
: Handles secure token and native currency transfers.
Last updated