building decentralized apps in go: meet gno

Fosdem, 1 Feb 2025, Brussels

Manfred Touron

VP Eng., gno.land

bonjour, FOSDEM!

package main

func main() {
    println("Hello, Fosdem! It's Manfred.")
}
2

why gno?

3

gno in one sentence

gno is a transactional vm
that lets you write decentralized apps in go,
with built-in state persistence and safe execution.

4

gno hello world

package hello

func Hello() string {
    return "hello world"
}
5

gno.land

we’re building a user-owned internet
where governance is fair,
development is open,
and innovation is rewarded.
6

the gno paradigm

... but it's just like go.

7

persistence: counter.gno

package counter

import "strconv"

var counter int

func Incr() {
    counter += 1
}

func Render(_ string) string {
    return "my decentralized counter: " + strconv.Itoa(counter)
}
8

microposts

9

microposts/post.gno

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
}
10

microposts/realm.gno

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
}
11

microposts demo

gnokey maketx call \
       -pkgpath "gno.land/r/leon/fosdem25/microposts" \
       -func "CreatePost" \
       -args "Hello FOSDEM people! Welcome <3" ...

gno.land/r/leon/fosdem25/microposts

12

interoperability: alice.gno & bob.gno

Another 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)
}
13

conclusion


we’re building a user-owned internet
where governance is fair,
development is open,
and innovation is rewarded.


thank you! 14

Thank you

Manfred Touron

VP Eng., gno.land

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)