📌Play To Earn Contract
Overview
The P2EGame
(Play-to-Earn Game) contract is designed for managing a gaming ecosystem where players can stake ERC20 tokens in a gaming escrow.
The contract handles the staking of tokens, tracks game states, and manages token payouts based on game outcomes.
Methods
gameState
gameState
Retrieves the current state of game funds in escrow.
Parameters
Parameter
Type
Description
_gameId
uint256
Identifier of the game.
_player
address
Address of the player.
Returns
Return
Type
Description
Tuple
(uint256, bool, address)
Balance, lock status, and treasury address.
createGame
createGame
Parameters
Parameter
Type
Description
_player
address
Address of the player.
_treasury
address
Treasury address for the game.
_p
uint256
Player's staked amount.
_t
uint256
Treasury's staked amount.
Returns
Return
Type
Description
success
bool
Returns true if the game is successfully created.
playerWon
playerWon
Parameters
Parameter
Type
Description
_gameId
uint256
Identifier of the game.
_player
address
Address of the winning player.
Returns
Return
Type
Description
success
bool
Returns true if tokens are unlocked successfully.
playerLost
playerLost
Parameters
Parameter
Type
Description
_gameId
uint256
Identifier of the game.
_player
address
Address of the losing player.
Returns
Return
Type
Description
success
bool
Returns true if funds are sent to treasury.
Withdraw
Withdraw
Parameters
Parameter
Type
Description
_gameId
uint256
Identifier of the game.
Returns
Return
Type
Description
success
bool
Returns true if withdrawal is successful.
Last updated