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

blog package

Overview

Package blog is moul's personal blog on gno.land: one realm, one author, posts that live in chain storage rather than in the code.

The shape

A post is markdown plus four fields (slug, title, date, tags). Writing one is a single Set transaction, so publishing never redeploys the realm and fixing a typo costs one small call instead of a new package path.

The reader-facing paths are deliberately short, because they get pasted into other people's chats:

Example
1gno.land/r/moul/blog             the index, newest first
2gno.land/r/moul/blog:<slug>      one post
3gno.land/r/moul/blog:t/<tag>     every post carrying a tag

Ordering without sort

gno has no sort.Slice, and avl.Tree iterates by key. So posts live in two trees: `posts` keyed by slug, for the O(log n) lookup a permalink needs, and `order` keyed by "<date>/<slug>", walked in reverse for newest-first. The date is YYYY-MM-DD precisely so that lexical order is chronological order, which is what makes the second tree free.

Versioning

gnomod.toml declares private = true, which lets the creator re-add the package at this exact path. That redeploy re-runs init() and WIPES every post here, so the markdown kept off chain is the source of truth and tools/gnoblog pushes it back. Trading that risk for a stable URL is the whole design: a /v1 would break every link already shared, a redeploy does not, and Manifest() makes restoring the content one diff.

Function

SetIntro

func SetIntro(cur realm, body string)

SetIntro replaces the markdown shown above the index. Passing "" restores the built-in header.

Param

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/moul/blog" -func "SetIntro" -args $'' -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/moul/blog" -func "SetIntro" -args $'' -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