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 counter implements "Counter Club": a single shared integer counter with a rolling history of the last 20 muta...

Readme View source

Counter Club

⚠️ 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


A single shared integer counter that anyone on the chain can nudge. Every call to Inc, Dec, or Reset mutates the global value and appends a record to a rolling log of the last 20 changes (caller address, delta, new value, block height). The realm's Render shows the current value big, the total number of changes ever made, and a table of the recent history.

Realm path: gno.land/r/REPLACE_ADDR/counter

Example calls

 1# Increment the shared counter
 2gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/counter" \
 3  -func Inc -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 KEY
 4
 5# Decrement it
 6gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/counter" \
 7  -func Dec -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 KEY
 8
 9# Reset back to zero
10gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/counter" \
11  -func Reset -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 KEY

View the current value and history by rendering the realm in a gno.land explorer or with gnokey query vm/qrender --data "gno.land/r/REPLACE_ADDR/counter:".


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

🧪 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 counter implements "Counter Club": a single shared integer counter with a rolling history of the last 20 mutations. Anyone may Inc, Dec, or Reset the value; every change records the caller, the delta applied, the resulting value, and the block height it happened at.

Functions 6

func Dec

crossing Action
1func Dec(cur realm) int
source

Dec subtracts one from the shared counter and logs the change.

func Inc

crossing Action
1func Inc(cur realm) int
source

Inc adds one to the shared counter and logs the change.

func Render

1func Render(path string) string
source

Render produces a Markdown view: the big current value, the total number of changes, and a table of the most recent changes (newest first).

func Reset

crossing Action
1func Reset(cur realm) int
source

Reset sets the shared counter back to zero and logs the change. The recorded delta is the amount required to bring the previous value to zero.

func Total

Action
1func Total() int
source

Total returns the total number of mutations ever applied.

func Value

Action
1func Value() int
source

Value returns the current counter value (read-only helper).

Imports 5

  • chain stdlib
  • chain/runtime stdlib
  • chain/runtime/unsafe stdlib
  • strconv stdlib
  • strings stdlib

Source Files 3