GameFactory

GameFactory

Inherits: IGameFactory, Ownable, Pausable

Facilitates the creation of new games

State Variables

MAXIMUM_GAME_CREATION_FEE

This uses 6 decimals because the contract uses USDC as the fee token

uint256 public constant MAXIMUM_GAME_CREATION_FEE = 100e6;

usdc

Address of the USDC token

IERC20 public immutable usdc;

vault

Address of the Vault contract

Vault public immutable vault;

revealer

Address of the Revealer contract

gameDuration

Duration of newly created games

claimableAfter

Duration at which the revealer can reveal the cards of newly created games

maxFreeReveals

Maximum amount of free reveals for newly created games

gameCreationFee

Fee of game creation in USDC

nextGameId

ID of the next Game

userGames

Number of games a user has created

referrals

Referrals program

referrerInvites

Number of players a referrer has invited

Functions

constructor

Initializes the GameFactory contract with specified parameters

Parameters

Name
Type
Description

_usdc

IERC20

The address of the USDC token

_vault

Vault

The address of the vault that will call the createGame function

_revealer

address

A trusted address used to initialize games and reveal player guesses

_gameDuration

uint256

The duration of each game, after which games expire

_claimableAfter

uint256

The duration which the user can claim their win if revealer does not reveal

_maxFreeReveals

uint256

The maximum amount of free reveals a player can request

_gameCreationFee

uint256

The fee required for players to create games

pause

Pauses the GameFactory from creating new games

Emits Paused event

unpause

Unpauses the GameFactory from creating new games

Emits Unpaused event

setGameCreationFee

Changes the fee required to create a new game

Emits GameFeeChanged event

Parameters

Name
Type
Description

_gameCreationFee

uint256

The new fee amount in USDC

setGameDuration

Changes the duration of future games

Emits GameDurationChanged event

Parameters

Name
Type
Description

_gameDuration

uint256

The new duration in seconds

setClaimableAfter

Changes the claimable duration of future games

Emits ClaimableAfterChanged event

Parameters

Name
Type
Description

_claimableAfter

uint256

The new duration in seconds

setMaxFreeReveals

Changes the maximum amount of free reveals a player can request for future games

Emits MaxFreeRevealsChanged event

Parameters

Name
Type
Description

_maxFreeReveals

uint256

The amount of free reveals a player can request

setRevealer

Changes the manager address for creating new games

Emits RevealerChanged event

Parameters

Name
Type
Description

_revealer

address

The new manager address

createGame

Creates a new game using the GameFactory contract and stores related data

The caller must pay at least the gameCreationFee amount to create a game

Emits GameCreated event

Parameters

Name
Type
Description

_referrer

address

The referrer of the player. Could be the 0x00 address if already set or if the player does not want to set one

Returns

Name
Type
Description

id

uint256

The ID of the newly created game

gameAddress

address

The address of the newly created game

games

Retrieves the details of a specific game

Parameters

Name
Type
Description

_gameId

uint256

The ID of the game

Returns

Name
Type
Description

<none>

GameDetails

Details of the specified game

Types

gameDetails

Last updated