Creating Games

How to create Gaambl Lotto games and configure game parameters

Game Creation Process

Creating a Gaambl Lotto game requires paying a creation fee and configuring game parameters. The creator automatically joins as the first player.

Key Points

  • • Creator automatically joins as first player
  • • Must pay creation fee (0.001 ETH) + entry fee
  • • Token must be whitelisted
  • • Game starts immediately after creation

Function Signature

function createGame(GameConfig memory config) external payable returns (uint256 gameId)

Game Configuration

The GameConfig struct contains all the parameters needed to create a game.

Token Settings

  • token: Payment token address (0x0 for ETH)
  • entryFee: Cost to join the game (in wei)
  • Requirements: Token must be whitelisted

Player Settings

  • maxPlayers: Maximum number of players (10-500)
  • Requirements: Must be between MIN_PLAYERS and MAX_PLAYERS
  • Auto-Join: Creator automatically joins as first player

Timing Settings

  • duration: Game duration in seconds (24 hours to 30 days)
  • Requirements: Must be between MIN_DURATION and MAX_DURATION
  • Auto-Complete: Game completes when max players reached or expired

Risk Mode

  • riskMode: Risk level (0=Moderate, 1=Aggressive, 2=High Risk, 3=Extreme)
  • Moderate: 25% of players win
  • Aggressive: 15% of players win
  • High Risk: 10% of players win
  • Extreme: 5% of players win

Game Information

  • title: Game title (max 100 bytes)
  • description: Game description (max 500 bytes)
  • Requirements: Both must be non-empty strings

Payment Requirements

When creating a game, you must pay both the creation fee and your entry fee.

Creation Fee

  • Amount: 0.001 ETH
  • Purpose: Platform fee for game creation
  • Payment: Always in ETH

Entry Fee

  • Amount: As specified in config.entryFee
  • Purpose: Your participation in the game
  • Payment: In specified token (ETH or ERC-20)

Example

Example of creating a game with ETH payments:

GameConfig memory config = GameConfig({
  token: address(0), // ETH
  entryFee: "0.01 ETH", // 0.01 ETH entry fee
  maxPlayers: 50,
  duration: 86400, // 24 hours
  riskMode: RiskMode.MODERATE, // 25% winners
  title: "My First Game",
  description: "A fun game for everyone!"
});

// Pay creation fee (0.001 ETH) + entry fee (0.01 ETH)
uint256 gameId = createGame{value: "0.011 ETH"}(config);

Validation Rules

The contract validates all game parameters before creation.

Parameter Validation

  • • maxPlayers must be between 10 and 500
  • • duration must be between 24 hours and 30 days
  • • entryFee must be greater than 0
  • • riskMode must be valid (0-3)
  • • token must be whitelisted

String Validation

  • • title must be non-empty and ≤ 100 bytes
  • • description must be non-empty and ≤ 500 bytes

Payment Validation

  • • Must pay exact creation fee + entry fee
  • • For ERC-20 tokens, must approve token transfer