Gamepot - a prize pool contract for off-chain games
Used at https://theuniverse.gg
Gamepot is a prize pooling contract for off chain games. Players add credits and join games with an ERC20 that's configured during creation of the game. The top x% of players are then paid out of the prize pool based on a leaderboard. A percent of the prize pool goes to the contract deployer as well as the game host.
The "off chain" part means that this assumes the contract is controlled by something off chain. Because of this, atomicity assumptions cannot be made and this shows itself in the startGame
function:
function startGame(uint game_id, address[] calldata players)
The game controller (off chain) must tell the contract which players actually made it into the game. This is to handle the race condition of:
The contract will refund all players who are not in that players array but have paid to join.
function joinGame(uint game_id) // join a game that hasn't started yet
function addCredits(uint game_id, uint amount) // add credits to balance
function getMyCreditBalance(uint game_id) // check my credit balance
function getCreditBalanceOf(uint game_id, address addr) // check balance of another player
Adding or removing mods can only be done by an owner.
function addMod(uint game_id, address mod) // add a mod to a game
function removeMod(uint game_id, address mod) // remove a mod from a game
function isModOrOwner(uint game_id, address addr) // checks if address is a mod or owner for a game
All game state changes must be called by a mod or owner. Owner is the creator of the game.
function resetGame(uint game_id) // reset game after it has been completed
function cancelGame(uint game_id) // cancels game and refunds everyone
game_id | uint256 |
amount | uint256 |
Oct 13, 2022
MIT, Unlicense