/r/nym-moultest123/demo/data/v0
gno.land/r/nym-moultest123/demo/data
Step 3 of the r/moul/demo walkthrough: realm state that persists between
transactions.
1var total int
2
3func init() { total = 1000 }
4func Add(nb int) int { total += nb; return total }
total is a package-level variable in a realm, so the VM persists it after
every call. init runs once, at deploy time, not on each call. Call Add(42)
then Add(295) and the second call returns 1337: the mutation from the first
one was committed to chain storage.
That is the whole difference between a p/ package (no state of its own) and
an r/ realm.
Previous: args. Next: render exposes state through
gnoweb.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.