Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

dice/v0 package

Overview

Package dice implements a provably-fair on-chain dice game for gno.land.

There is no true randomness on-chain: every node must reach the same result deterministically. Instead, each roll derives its 1-6 face from public block entropy (chain height) mixed with the caller address and the caller's roll count. The derivation is fully reproducible from public data, which is what "provably fair" means here — anyone can recompute a roll and verify it.

Function

Roll

func Roll(cur realm) int

Roll performs one dice roll for the calling account and records it.

It is a crossing function (gno 0.9 interrealm convention: `cur realm` first parameter). Callers invoke it as Roll(cross(cur)). The result is derived deterministically from the current block height, the caller address, and the caller's prior roll count — no stored secret, fully verifiable.

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/dice/v0" -func "Roll" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/dice/v0" -func "Roll" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx