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

reactions/v0 package

Overview

Package reactions is a reaction block any realm can embed, keyed on the page it appears on rather than on the realm that stores it.

It is the shape the web settled on for this in 2010: one hosted widget, the same snippet pasted everywhere, deciding what to show from the page identifier it is handed. Here the snippet is two lines of gno:

Example
1import "gno.land/r/moul/reactions/v0"
2
3func Render(path string) string {
4	return body + reactions.RenderBlock()
5}

RenderBlock takes no argument because it does not need one: a plain read exported by a realm and called by another opens no realm frame, so unsafe.CurrentRealm() inside it reports the CALLER. The host realm's own path is the page key, and nothing has to be configured, registered or passed. RenderBlockFor is the explicit form, for a realm that renders more than one page or already holds its path as a constant.

The host realm stores nothing. Every tally lives here, so a realm can add reactions without a redeploy the next time it wants to change them, and a reader's reaction survives the host realm being replaced.

What it is not

Not a comment system. There is no text field anywhere, which is what makes it possible to run with no moderation at all: six emoji, one reaction per address per page, changeable and removable. The page shows the tally and who reacted last. That is the whole feature.

Function

React

func React(cur realm, page, key string)

React records the caller's reaction to page.

page is a package path, the full one: "gno.land/r/moul/home". It does not have to be a realm that embeds the block, and nothing checks that it exists. A page is just a name, which is what lets a realm key the block on something finer than itself.

key is one of the palette names, not a glyph: "up", "heart", "fire", "party", "rocket", "eyes". Render("") lists them with their emoji.

One reaction per address per page. Reacting again with a different key moves it; reacting with the same key changes nothing but the "last reaction" line.

Params

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/reactions/v0" -func "React" -args $'' -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/reactions/v0" -func "React" -args $'' -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