fairroulette

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2021 License: Apache-2.0, BSD-2-Clause, Apache-2.0, + 1 more Imports: 1 Imported by: 0

README

fairroulette

Sample smart contract

A simple betting contract. Betters can bet on a random color and after
a predefined time period the contract will automatically pay the total
bet amount proportionally to the bet size of the winners. 

Documentation

Index

Constants

View Source
const (
	ScName  = "fairroulette"
	HScName = wasmlib.ScHname(0xdf79d138)
)
View Source
const (
	ParamNumber     = wasmlib.Key("number")
	ParamPlayPeriod = wasmlib.Key("playPeriod")
)
View Source
const (
	ResultLastWinningNumber = wasmlib.Key("lastWinningNumber")
	ResultRoundNumber       = wasmlib.Key("roundNumber")
	ResultRoundStartedAt    = wasmlib.Key("roundStartedAt")
	ResultRoundStatus       = wasmlib.Key("roundStatus")
)
View Source
const (
	StateBets              = wasmlib.Key("bets")
	StateLastWinningNumber = wasmlib.Key("lastWinningNumber")
	StatePlayPeriod        = wasmlib.Key("playPeriod")
	StateRoundNumber       = wasmlib.Key("roundNumber")
	StateRoundStartedAt    = wasmlib.Key("roundStartedAt")
	StateRoundStatus       = wasmlib.Key("roundStatus")
)
View Source
const (
	FuncForcePayout       = "forcePayout"
	FuncForceReset        = "forceReset"
	FuncPayWinners        = "payWinners"
	FuncPlaceBet          = "placeBet"
	FuncPlayPeriod        = "playPeriod"
	ViewLastWinningNumber = "lastWinningNumber"
	ViewRoundNumber       = "roundNumber"
	ViewRoundStartedAt    = "roundStartedAt"
	ViewRoundStatus       = "roundStatus"
)
View Source
const (
	HFuncForcePayout       = wasmlib.ScHname(0x555a4c4f)
	HFuncForceReset        = wasmlib.ScHname(0xa331951e)
	HFuncPayWinners        = wasmlib.ScHname(0xfb2b0144)
	HFuncPlaceBet          = wasmlib.ScHname(0xdfba7d1b)
	HFuncPlayPeriod        = wasmlib.ScHname(0xcb94b293)
	HViewLastWinningNumber = wasmlib.ScHname(0x2f5f09fe)
	HViewRoundNumber       = wasmlib.ScHname(0x0dcfe520)
	HViewRoundStartedAt    = wasmlib.ScHname(0x725de8b4)
	HViewRoundStatus       = wasmlib.ScHname(0x145053b5)
)
View Source
const (
	IdxParamNumber             = 0
	IdxParamPlayPeriod         = 1
	IdxResultLastWinningNumber = 2
	IdxResultRoundNumber       = 3
	IdxResultRoundStartedAt    = 4
	IdxResultRoundStatus       = 5
	IdxStateBets               = 6
	IdxStateLastWinningNumber  = 7
	IdxStatePlayPeriod         = 8
	IdxStateRoundNumber        = 9
	IdxStateRoundStartedAt     = 10
	IdxStateRoundStatus        = 11
)
View Source
const DefaultPlayPeriod = 60

The default playing period of one betting round in seconds.

View Source
const EnableSelfPost = true

Enable this if you deploy the contract to an actual node. It will pay out the prize after a certain timeout.

View Source
const MaxNumber = 8

The maximum number one can bet on. The range of numbers starts at 1.

View Source
const NanoTimeDivider = 1000_000_000

The number to divide nano seconds to seconds.

Variables

This section is empty.

Functions

func OnLoad

func OnLoad()

Types

type ArrayOfImmutableBet

type ArrayOfImmutableBet struct {
	// contains filtered or unexported fields
}

func (ArrayOfImmutableBet) GetBet

func (a ArrayOfImmutableBet) GetBet(index int32) ImmutableBet

func (ArrayOfImmutableBet) Length

func (a ArrayOfImmutableBet) Length() int32

type ArrayOfMutableBet

type ArrayOfMutableBet struct {
	// contains filtered or unexported fields
}

func (ArrayOfMutableBet) Clear

func (a ArrayOfMutableBet) Clear()

func (ArrayOfMutableBet) GetBet

func (a ArrayOfMutableBet) GetBet(index int32) MutableBet

func (ArrayOfMutableBet) Length

func (a ArrayOfMutableBet) Length() int32

type Bet

type Bet struct {
	Amount int64
	Better wasmlib.ScAgentID
	Number int64
}

func NewBetFromBytes

func NewBetFromBytes(bytes []byte) *Bet

func (*Bet) Bytes

func (o *Bet) Bytes() []byte

type ForcePayoutCall

type ForcePayoutCall struct {
	Func *wasmlib.ScFunc
}

type ForcePayoutContext

type ForcePayoutContext struct {
	State MutableFairRouletteState
}

type ForceResetCall

type ForceResetCall struct {
	Func *wasmlib.ScFunc
}

type ForceResetContext

type ForceResetContext struct {
	State MutableFairRouletteState
}

type Funcs

type Funcs struct{}
var ScFuncs Funcs

func (Funcs) ForcePayout

func (sc Funcs) ForcePayout(ctx wasmlib.ScFuncCallContext) *ForcePayoutCall

func (Funcs) ForceReset

func (sc Funcs) ForceReset(ctx wasmlib.ScFuncCallContext) *ForceResetCall

func (Funcs) LastWinningNumber

func (sc Funcs) LastWinningNumber(ctx wasmlib.ScViewCallContext) *LastWinningNumberCall

func (Funcs) PayWinners

func (sc Funcs) PayWinners(ctx wasmlib.ScFuncCallContext) *PayWinnersCall

func (Funcs) PlaceBet

func (sc Funcs) PlaceBet(ctx wasmlib.ScFuncCallContext) *PlaceBetCall

func (Funcs) PlayPeriod

func (sc Funcs) PlayPeriod(ctx wasmlib.ScFuncCallContext) *PlayPeriodCall

func (Funcs) RoundNumber

func (sc Funcs) RoundNumber(ctx wasmlib.ScViewCallContext) *RoundNumberCall

func (Funcs) RoundStartedAt

func (sc Funcs) RoundStartedAt(ctx wasmlib.ScViewCallContext) *RoundStartedAtCall

func (Funcs) RoundStatus

func (sc Funcs) RoundStatus(ctx wasmlib.ScViewCallContext) *RoundStatusCall

type ImmutableBet

type ImmutableBet struct {
	// contains filtered or unexported fields
}

func (ImmutableBet) Exists

func (o ImmutableBet) Exists() bool

func (ImmutableBet) Value

func (o ImmutableBet) Value() *Bet

type ImmutableFairRouletteState

type ImmutableFairRouletteState struct {
	// contains filtered or unexported fields
}

func (ImmutableFairRouletteState) Bets

func (ImmutableFairRouletteState) LastWinningNumber

func (s ImmutableFairRouletteState) LastWinningNumber() wasmlib.ScImmutableInt64

func (ImmutableFairRouletteState) PlayPeriod

func (ImmutableFairRouletteState) RoundNumber

func (ImmutableFairRouletteState) RoundStartedAt

func (ImmutableFairRouletteState) RoundStatus

type ImmutableLastWinningNumberResults

type ImmutableLastWinningNumberResults struct {
	// contains filtered or unexported fields
}

func (ImmutableLastWinningNumberResults) LastWinningNumber

type ImmutablePlaceBetParams

type ImmutablePlaceBetParams struct {
	// contains filtered or unexported fields
}

func (ImmutablePlaceBetParams) Number

type ImmutablePlayPeriodParams

type ImmutablePlayPeriodParams struct {
	// contains filtered or unexported fields
}

func (ImmutablePlayPeriodParams) PlayPeriod

type ImmutableRoundNumberResults

type ImmutableRoundNumberResults struct {
	// contains filtered or unexported fields
}

func (ImmutableRoundNumberResults) RoundNumber

type ImmutableRoundStartedAtResults

type ImmutableRoundStartedAtResults struct {
	// contains filtered or unexported fields
}

func (ImmutableRoundStartedAtResults) RoundStartedAt

type ImmutableRoundStatusResults

type ImmutableRoundStatusResults struct {
	// contains filtered or unexported fields
}

func (ImmutableRoundStatusResults) RoundStatus

type LastWinningNumberCall

type LastWinningNumberCall struct {
	Func    *wasmlib.ScView
	Results ImmutableLastWinningNumberResults
}

type LastWinningNumberContext

type LastWinningNumberContext struct {
	Results MutableLastWinningNumberResults
	State   ImmutableFairRouletteState
}

type MutableBet

type MutableBet struct {
	// contains filtered or unexported fields
}

func (MutableBet) Exists

func (o MutableBet) Exists() bool

func (MutableBet) SetValue

func (o MutableBet) SetValue(value *Bet)

func (MutableBet) Value

func (o MutableBet) Value() *Bet

type MutableFairRouletteState

type MutableFairRouletteState struct {
	// contains filtered or unexported fields
}

func (MutableFairRouletteState) Bets

func (MutableFairRouletteState) LastWinningNumber

func (s MutableFairRouletteState) LastWinningNumber() wasmlib.ScMutableInt64

func (MutableFairRouletteState) PlayPeriod

func (MutableFairRouletteState) RoundNumber

func (MutableFairRouletteState) RoundStartedAt

func (s MutableFairRouletteState) RoundStartedAt() wasmlib.ScMutableInt32

func (MutableFairRouletteState) RoundStatus

type MutableLastWinningNumberResults

type MutableLastWinningNumberResults struct {
	// contains filtered or unexported fields
}

func (MutableLastWinningNumberResults) LastWinningNumber

type MutablePlaceBetParams

type MutablePlaceBetParams struct {
	// contains filtered or unexported fields
}

func (MutablePlaceBetParams) Number

type MutablePlayPeriodParams

type MutablePlayPeriodParams struct {
	// contains filtered or unexported fields
}

func (MutablePlayPeriodParams) PlayPeriod

type MutableRoundNumberResults

type MutableRoundNumberResults struct {
	// contains filtered or unexported fields
}

func (MutableRoundNumberResults) RoundNumber

type MutableRoundStartedAtResults

type MutableRoundStartedAtResults struct {
	// contains filtered or unexported fields
}

func (MutableRoundStartedAtResults) RoundStartedAt

type MutableRoundStatusResults

type MutableRoundStatusResults struct {
	// contains filtered or unexported fields
}

func (MutableRoundStatusResults) RoundStatus

type PayWinnersCall

type PayWinnersCall struct {
	Func *wasmlib.ScFunc
}

type PayWinnersContext

type PayWinnersContext struct {
	State MutableFairRouletteState
}

type PlaceBetCall

type PlaceBetCall struct {
	Func   *wasmlib.ScFunc
	Params MutablePlaceBetParams
}

type PlaceBetContext

type PlaceBetContext struct {
	Params ImmutablePlaceBetParams
	State  MutableFairRouletteState
}

type PlayPeriodCall

type PlayPeriodCall struct {
	Func   *wasmlib.ScFunc
	Params MutablePlayPeriodParams
}

type PlayPeriodContext

type PlayPeriodContext struct {
	Params ImmutablePlayPeriodParams
	State  MutableFairRouletteState
}

type RoundNumberCall

type RoundNumberCall struct {
	Func    *wasmlib.ScView
	Results ImmutableRoundNumberResults
}

type RoundNumberContext

type RoundNumberContext struct {
	Results MutableRoundNumberResults
	State   ImmutableFairRouletteState
}

type RoundStartedAtCall

type RoundStartedAtCall struct {
	Func    *wasmlib.ScView
	Results ImmutableRoundStartedAtResults
}

type RoundStartedAtContext

type RoundStartedAtContext struct {
	Results MutableRoundStartedAtResults
	State   ImmutableFairRouletteState
}

type RoundStatusCall

type RoundStatusCall struct {
	Func    *wasmlib.ScView
	Results ImmutableRoundStatusResults
}

type RoundStatusContext

type RoundStatusContext struct {
	Results MutableRoundStatusResults
	State   ImmutableFairRouletteState
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL