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

fishptr.gno

package fishptr

const capFish = 128

type fish struct {
	owner address
	name  string
	bite  int
	on    bool
}

var (
	minted int
	roster [capFish + 1]fish
)

func Version() string { return "ptr-1" }

func mustFish(id int) *fish {
	if id < 1 || id > minted {
		panic("fish")
	}
	return &roster[id]
}

func NameOf(id int) string { return mustFish(id).name }

func Mark(id int) {
	row := mustFish(id)
	row.on = true
	row.bite = 24
}

func Plant(caller address) int {
	if minted >= capFish {
		panic("full")
	}
	minted++
	roster[minted].owner = caller
	roster[minted].name = "Bubble"
	return minted
}

gnomod.toml

module = "gno.land/r/g10ragdr3cjqkael8rslpw4y6rlelhev4h0fswcx/fishptr"
gno = "0.9"

[addpkg]
  creator = "g10ragdr3cjqkael8rslpw4y6rlelhev4h0fswcx"
  height = 329419
  max_deposit = "10000000ugnot"