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

connect4 package

Overview

Package connect4 is a staked Connect 4 game. A creator posts an offer with a ugnot stake; anyone (or a named opponent) accepts with the same stake; the winner takes the pot minus a flat house fee.

The first mover is picked by a two-sided commit-reveal. The creator offers with sha256(passphrase), the acceptor accepts with sha256(seed). Then the creator reveals the passphrase (Reveal) and the acceptor the seed (RevealSeed), each within 90s, and the first mover is drawn from both. When a player commits, the other side's secret is still hidden, so neither can grind for an outcome, and once its secret is revealed nobody can change it; the only way out is to not reveal, which forfeits. Watching a pending Accept tells the creator nothing either, so it cannot cancel unfavourable games. Each address may use a commitment once: a reused secret is already public.

Calls signed by an account session key (Quick play) may only Play, Reveal, RevealSeed, ClaimTimeout and Cancel: a stolen session key must not resign games, move stakes or act as the owner.

Every move has a 90s clock measured in block time. Nothing on-chain fires by itself, so an expired clock is settled by anyone calling ClaimTimeout: whoever did not reveal in time forfeits, a game whose first mover never moved is void and both stakes are refunded, otherwise the player who ran out of time forfeits.

Function

AcceptOwnership

func AcceptOwnership(cur realm)

AcceptOwnership completes a TransferOwnership; only the named address may call it.

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/samcrew/connect4" -func "AcceptOwnership" -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/samcrew/connect4" -func "AcceptOwnership" -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