Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

README.md

2.79 Kb · 61 lines

gno.land/r/moul/demo/render

Step 4 of the r/moul/demo walkthrough: Render, the read-only view a realm exposes to gnoweb.

1func Render(path string) string

Render receives whatever follows the : in the URL and routes on it. Three routes are wired here:

path output
"" an index linking to the other two
"hello" Hello World!
"greetings/<name>" Welcome, <Name>!
anything else 404

Render is a query, not a transaction: no gas, no signature, and it must be deterministic.

1gnokey query vm/qrender -data 'gno.land/r/moul/demo/render:greetings/manfred' \
2  -remote https://rpc.gno.land:443

Caveat, kept on purpose. The index route still emits links to /r/moul_basics_004:, the path this code was written against in an older workshop. They do not resolve at this realm's current path. It is a good illustration of the trap: a hardcoded self-link becomes wrong the moment the realm moves, so build links from the request path (see p/moul/realmpath) instead.

Previous: data. Next: wikicoin builds a ledger.

It knows when it is old

Render prepends reg.Banner("render", self) from r/moul/releases, the registry of which version of each project is the latest. While this is the latest version of render the banner is empty; once a newer one is listed, this page says so and links to it, with no change to this code. self is computed once at init from unsafe.CurrentRealm().


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

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

gno.land/r/moul/demo/render/v1 dependency graph

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.