Security

Lotto Balls is designed with security as a core principle. This page outlines the security measures and considerations.

Smart Contract Security

Reentrancy Protection

The contract inherits from OpenZeppelin's ReentrancyGuard:

function play(...) external payable nonReentrant whenNotPaused onlyWhitelisted

All state changes occur before external calls, following the checks-effects-interactions pattern.

Pausability

The contract can be paused in emergencies:

function pause() external onlyOwner
function unpause() external onlyOwner

When paused:

  • No new bets can be placed

  • Pending VRF callbacks can still complete

  • Admin functions remain accessible

Access Control

Multiple layers of access control:

Function
Protection

play()

onlyWhitelisted (requires LAZER token)

Admin functions

onlyOwner

VRF callback

Only VRF Coordinator can call

External caller

Must be whitelisted via setExternalCaller

Single Pending Bet

Players can only have one pending bet:

This prevents:

  • Bet flooding attacks

  • Complex multi-bet exploits

  • VRF callback confusion

Randomness Security

VRF (Verifiable Random Function) ensures:

  • Unpredictability: Numbers cannot be predicted before reveal

  • Verifiability: Cryptographic proof of fairness

  • Tamper resistance: Cannot be manipulated by any party

Number Derivation

Four numbers are derived from a single VRF word:

This ensures:

  • Uniform distribution (0-9 for each position)

  • Deterministic derivation (verifiable)

  • No correlation between positions

Financial Security

Fee Distribution

USDC fees are immediately transferred to the owner:

Jackpot Protection

Multiple safeguards for the prize pool:

  1. Buffer Rate (30%): Reserved funds never paid out

  2. Jackpot Cap: Maximum single payout limit

  3. No negative balances: Transfers check balances

LTB Transfer Safety

LTB transfers check balance before sending:

Emergency Procedures

Manual Game Override

If a VRF callback fails (extremely rare):

This:

  • Unlocks the stuck player

  • Does NOT award any prizes

  • Logs the override for transparency

Fund Withdrawal

Owner can withdraw funds if needed:

Known Considerations

Token Approval Requirements

Players must approve tokens before playing. The contract does not implement permit() - standard approve() is required.

VRF Callback Gas

The callback has a gas limit (800,000). Complex operations could theoretically exceed this, though the current implementation is well within limits.

Centralization Points

The owner address has significant control:

  • Pause/unpause the contract

  • Modify payout amounts

  • Withdraw funds

  • Override stuck games

Users should be aware of this trust assumption.

Audit Status

Users should verify the audit status of the contracts before depositing significant funds. Look for:

  • Third-party security audits

  • Bug bounty programs

  • Time the contracts have been live without issues

Reporting Vulnerabilities

If you discover a security vulnerability:

  1. Do NOT disclose publicly

  2. Contact the team through official channels

  3. Allow reasonable time for a fix

  4. Responsible disclosure is appreciated and may be rewarded

Last updated