building decentralized apps in go: meet gno
Fosdem, 1 Feb 2025, Brussels
Manfred Touron
VP Eng., gno.land
Manfred Touron
VP Eng., gno.land
package main func main() { println("Hello, Fosdem! It's Manfred.") }
gno is a transactional vm
that lets you write decentralized apps in go,
with built-in state persistence and safe execution.
package hello func Hello() string { return "hello world" }
we’re building a user-owned internet where governance is fair, development is open, and innovation is rewarded.
import
... but it's just like go.
7package counter import "strconv" var counter int func Incr() { counter += 1 } func Render(_ string) string { return "my decentralized counter: " + strconv.Itoa(counter) }
package microposts import ( "std" "time" ) type Post struct { text string author std.Address createdAt time.Time } func (p Post) String() string { out := p.text + "\n" out += "_" + p.createdAt.Format("02 Jan 2006, 15:04") + ", by " + p.author.String() + "_" return out }
package microposts import ( "std" "time" ) var posts []*Post // automatically persisted func CreatePost(text string) { posts = append(posts, &Post{ text: text, author: std.PrevRealm().Addr(), // provided by env createdAt: time.Now(), }) } func Render(_ string) string { out := "# Posts\n" for i := len(posts) - 1; i >= 0; i-- { out += "### Post " + strconv.Itoa(i) + "\n" + posts[i].String() } return out }
gnokey maketx call \ -pkgpath "gno.land/r/leon/fosdem25/microposts" \ -func "CreatePost" \ -args "Hello FOSDEM people! Welcome <3" ...
gno.land/r/leon/fosdem25/microposts
12Another app could use micropost...
package alice var x int func GetX() int { return x } func SetX(n int) { x = n }
package bob import "alice" func IncrAlice() { x := alice.GetX() alice.SetX(x + 1) }
we’re building a user-owned internet where governance is fair, development is open, and innovation is rewarded.