name: FairRoulette
description: ""
events:
  bet:
    address: Address # address of better
    amount: Uint64 # amount of tokens to bet
    number: Uint16 # number to bet on
  payout:
    address: Address # address of winner
    amount: Uint64 # amount of tokens won
  round:
    number: Uint32 # current betting round number
  start:
  stop:
  winner:
    number: Uint16 # the winning number
structs:
  Bet:
    amount: Uint64
    better: AgentID
    number: Uint16
typedefs: {}
state:
  bets: Bet[]
  lastWinningNumber: Uint16
  owner: AgentID?
  playPeriod: Uint32
  roundNumber: Uint32
  roundStartedAt: Uint32
  roundStatus: Uint16
funcs:
  init:
    params:
      owner: AgentID?
  payWinners:
    access: self # only SC itself can invoke this function
  placeBet:
    params:
      number: Uint16 # the number a better bets on
  forceReset:
    access: owner # only SC owner can restart the round forcefully
  forcePayout:
    access: owner # only SC owner can restart the round forcefully
  playPeriod:
    access: owner # only SC owner can update the play period
    params:
      playPeriod: Uint32 # number of minutes in one playing round
views:
  lastWinningNumber:
    results:
      lastWinningNumber: Uint16
  roundNumber:
    results:
      roundNumber: Uint32
  roundStartedAt:
    results:
      roundStartedAt: Uint32
  roundStatus:
    results:
      roundStatus: Uint16
