Peer2Play WhitePaper
  • 📜Introduction
  • ⛔Problem Statement
  • đŸ› ī¸Solution
  • đŸŽ¯Mission and Vision
  • ⚡Key Features
    • Game Tokenization
    • Developer On-Boarding
    • Player-Driven Ecosystem
    • Transparent Revenue Sharing
    • On-chain Tournaments
    • Tokenized Economy
    • Cross-Chain Integration
    • Governance and Incentives
      • GameDAO
      • Incentives
    • Co-Ownership Model
      • Tokenized Games
      • Buybacks and Burns
  • 🤖AI Agents
  • Games
    • âœ‚ī¸Punk Paper(LIVE)
    • 🏏Decentralized Cricket League (DCL)(LIVE)
    • đŸ‹ī¸Chain Duel(Coming Soon)
    • đŸ•šī¸Upcoming Games
  • 🧩Use cases
  • đŸ’ĢGetting started
    • Game Developers
    • Influencers
    • Gamers
  • 👨‍đŸ’ģTechnical Architecture
    • MPC Wallet
    • Smart contract Architecture
      • Peer2PlayGenericStakingContract
        • Chess
        • Poker
        • Ludo
      • Peer2PlayGenericNonStakingContract
        • 1. Role-Playing Game (RPG)
        • 2. City-Building Game
        • 3. Farming Simulations
      • Tokenization & Revenue distribution
    • SDKs & APIs
  • 🔐Compliance & Security
  • ❓FAQ & Troubleshooting
  • 🤝Connect with Peer2Play
Powered by GitBook
On this page
  • Imports Used & Their Significance
  • State Variables
  • Function Descriptions
  1. Technical Architecture
  2. Smart contract Architecture

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

  1. ReentrancyGuard: Prevents reentrancy attacks.

  2. Ownable: Grants admin privileges for sensitive functions.

  3. Pausable: Enables emergency stops for games or the entire platform.

  4. 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

  1. addGame: Adds a new game to the platform.

  2. updateGameFee: Allows game owners to adjust their game fee.

  3. pauseGame: Temporarily halts a game for maintenance or issues.

  4. unpauseGame: Resumes operations for a paused game.

  5. removeGame: Deletes a game from the platform.

Fee & Token Management

  1. setProtocolFee: Sets platform-wide fees for matches.

  2. setDrawFee: Defines fees for matches that end in a draw.

  3. allowToken: Adds or updates eligible staking tokens.

Match Lifecycle

  1. createMatch: Initializes a new match with customizable parameters.

  2. joinMatch: Enables players to join matches, verifying authorization for private matches.

  3. submitMatchResult: Submits results and distributes rewards or refunds.

  4. cancelMatch: Cancels a match and refunds participants.

Internal Utilities

  1. _handleDraw: Handles refunds for drawn matches.

  2. _amountAfterCut: Computes net amount after deducting fees.

  3. _transferFunds: Handles secure token and native currency transfers.

PreviousSmart contract ArchitectureNextChess

Last updated 4 months ago

👨‍đŸ’ģ