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

v0 source realm

Package rpsduel is an asynchronous, two-player rock-paper-scissors duel with a commit-reveal handshake. The challenge...

Readme View source

Rock-Paper-Scissors Duel

⚠️ Experimental — generated with no human supervision. This realm was produced automatically by an MCP-driven agent to exercise the gno MCP server and tooling, and to generate test content for gno compilers, linters and formatters. Not audited. Not for production. Full context & folder README: r/moul/x/daily


Asynchronous, two-player rock-paper-scissors with a real commit-reveal handshake: the challenger locks in a move as a sha256 commitment, the opponent replies in the open (seeing only a hash gives them nothing to go on), and the challenger reveals last to settle the round. A challenger who tries to dodge a losing reveal can be forfeited by the opponent once a 50-block reveal window expires — no house move, no single-tx shortcut, just two players and a fairness primitive.

Realm path: gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel

Example calls

 1# 1. Compute your commitment off-chain (or via a read-only query)
 2gnokey query vm/qeval \
 3  --data 'gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel.ComputeCommit("rock", "xyz123")'
 4
 5# 2. Open a duel against an opponent with that commitment
 6gnokey maketx call \
 7  -pkgpath "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel" \
 8  -func Open -args "g1opponentaddr..." -args "<64-char hex commit>" \
 9  -gas-fee 1000000ugnot -gas-wanted 3000000 -broadcast -chainid sapphire-1 <key>
10
11# 3. Opponent replies in the clear
12gnokey maketx call \
13  -pkgpath "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel" \
14  -func Accept -args "1" -args "paper" \
15  -gas-fee 1000000ugnot -gas-wanted 3000000 -broadcast -chainid sapphire-1 <key>
16
17# 4. Challenger reveals to settle it
18gnokey maketx call \
19  -pkgpath "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel" \
20  -func Reveal -args "1" -args "rock" -args "xyz123" \
21  -gas-fee 1000000ugnot -gas-wanted 3000000 -broadcast -chainid sapphire-1 <key>
22
23# View the lobby, a specific duel, or a player's record
24gnokey query vm/qrender --data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel:"
25gnokey query vm/qrender --data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/rpsduel:1"

Toolchain status

Compiled and tested against the chain/sapphire (gno 0.9) toolchain tag from gnolang/gnogno test . and gno lint . both pass clean.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/x/daily/rpsduel/v0 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package rpsduel is an asynchronous, two-player rock-paper-scissors duel with a commit-reveal handshake. The challenger locks in a move as a sha256 commitment up front so the opponent can't peek at it; the opponent then replies in the clear (seeing only a hash gives them no edge); the challenger reveals last to settle the round. A challenger who tries to dodge a losing reveal can be forfeited by the opponent once the reveal window expires.

Constants 1

Functions 7

func Accept

crossing Action
1func Accept(cur realm, id string, moveStr string) string
source

Accept replies to a pending duel with a plain move. Only the challenged opponent may call it; going second behind the challenger's hidden commitment is what keeps this fair.

func Cancel

crossing Action
1func Cancel(cur realm, id string) string
source

Cancel withdraws a still-pending duel. Only the challenger may cancel, and only before the opponent accepts.

func ClaimForfeit

crossing Action
1func ClaimForfeit(cur realm, id string) string
source

ClaimForfeit lets the opponent collect a default win when the challenger dodges revealing (e.g. because they saw the opponent's move and knew they'd lose) past the reveal window.

func ComputeCommit

Action
1func ComputeCommit(moveStr, salt string) string
source

ComputeCommit hashes a move and salt exactly the way Reveal checks it, so a caller can compute their commitment (e.g. via a read-only query) before calling Open, then remember the salt to pass to Reveal later.

func Open

crossing Action
1func Open(cur realm, opponentAddr string, commitHex string) string
source

Open challenges opponentAddr to a duel, locking in the challenger's move as a commitment (see ComputeCommit) so the opponent can't see it before replying.

func Render

1func Render(path string) string
source

Render shows the duel lobby at "", a specific duel when path is a numeric ID, or one player's record when path is their bech32 address.

func Reveal

crossing Action
1func Reveal(cur realm, id string, moveStr string, salt string) string
source

Reveal settles an accepted duel. Only the original challenger may call it, and only with the exact move+salt that produced their commitment.

Types 1

type Move

ident
1type Move int
source

Move is one of rock, paper, or scissors, ordered so that (winner - loser + 3) % 3 == 1 for every winning pair.

Imports 7

Source Files 3