Smart Contracts

This page provides a technical overview of the Lotto Balls smart contract architecture.

Contract Overview

Contract
Purpose

LottoBalls.sol

Main game logic, betting, VRF integration

LTB.sol

ERC-20 token with role-based access

LottoBalls Contract

The main game contract handles all betting, randomness, and payout logic.

Inheritance

contract LottoBalls is
    ReentrancyGuard,      // Prevents reentrancy attacks
    Pausable,             // Emergency pause functionality
    VRFConsumerBaseV2Plus, // Chainlink VRF integration
    ILottoBalls           // Interface definition

State Variables

Tokens

IERC20 public ltbToken;    // LTB token contract
IERC20 public usdc;        // USDC token contract
IERC20 public lazerToken;  // Whitelist access token

Game Configuration

Tracking

Bet Structure

Core Functions

play()

  • Validates player has whitelist token

  • Ensures no pending bet exists

  • Transfers payment (USDC or LTB)

  • Requests VRF random number

  • Emits GameRequested event

fulfillRandomWords()

  • Called by Chainlink VRF with random number

  • Derives 4 numbers from single random word

  • Calculates matches

  • Distributes prizes (USDC and/or LTB)

  • Emits GameResolved event

View Functions

Admin Functions

LTB Token Contract

Standard ERC-20 with role-based minting/burning.

Roles

Privileged Functions

Events

GameRequested

Emitted when a bet is placed successfully.

GameResolved

Emitted when VRF fulfills and the bet is resolved.

ManualGameOverride

Emitted when admin manually resolves a stuck bet.

Constants

External Dependencies

Dependency
Purpose

OpenZeppelin ReentrancyGuard

Reentrancy protection

OpenZeppelin Pausable

Emergency circuit breaker

OpenZeppelin IERC20

Token interface

Chainlink VRFConsumerBaseV2Plus

VRF integration

Chainlink VRFV2PlusClient

VRF request building

Last updated