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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

Playground

echo.gno

// Package echo is gnotif's demo realm: Echo sends a message back to its
// caller as a browser notification.
package echo

import (
	"chain"

	"gno.land/r/nym-gfanton001/gnotif/v0"
)

// The registry sees this realm as the caller, so the trigger is verified.
func init(cur realm) {
	gnotif.Declare(cross(cur), cur.PkgPath(), "Echo", "", "to", "Echo", "{msg}", "/")
}

// Echo sends msg to the browsers that opted in with the caller's address.
// The recipient is always the caller, so nobody can notify another address.
func Echo(cur realm, msg string) {
	chain.Emit("Echo", "to", cur.Previous().Address().String(), "msg", msg)
}

// Render serves one page for every path: what Echo does and where to try it.
func Render(_ string) string {
	return "# Echo\n\n" +
		"Call `Echo` with a message, and gnotif shows it as a notification in the browsers " +
		"that turned on notifications for your own address. Nobody else can send one to you.\n\n" +
		"Try it on [demo.gnotif.xyz](https://demo.gnotif.xyz).\n"
}

gnomod.toml

module = "gno.land/r/nym-gfanton001/echo/v0"
gno = "0.9"

[addpkg]
  creator = "g18me5p9kqqxyswd8ytrmlv3q8kvy7uacx2v90ne"
  height = 256571
  max_deposit = "10000000ugnot"