Skip to content Search Apps Documentation Source Content 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.

realm.gno

0.44 Kb · 25 lines
 1package microposts
 2
 3import (
 4	"chain/runtime/unsafe"
 5	"strconv"
 6	"time"
 7)
 8
 9var posts []*Post
10
11func CreatePost(text string) {
12	posts = append(posts, &Post{
13		text:      text,
14		author:    unsafe.PreviousRealm().Address(), // provided by env
15		createdAt: time.Now(),
16	})
17}
18
19func Render(_ string) string {
20	out := "# Posts\n"
21	for i := len(posts) - 1; i >= 0; i-- {
22		out += "### Post " + strconv.Itoa(i) + "\n" + posts[i].String()
23	}
24	return out
25}