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

Playground

contract.gno

package grc20

import (
	"chain/runtime/unsafe"

	tokens "gno.land/p/nt/grc20/v0"
)

// test1 receives the initial mint at construction.
var test1 = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5")

// Token is exported. Other contracts can read it (balances, metadata).
// privateLedger stays unexported: it grants unrestricted mint/burn/transfer.
var (
	Token         *tokens.Token
	privateLedger *tokens.PrivateLedger
)

func init(cur realm) {
	// generate the token and mint some tokens to test1.
	Token, privateLedger = tokens.NewToken("Foo Token", "FOO", 4, 0, cur)
	privateLedger.Mint(test1, 100000000)
}

func MyBalance() int64 {
	return Token.BalanceOf(unsafe.OriginCaller())
}

gnomod.toml

module = "gno.land/r/moul/demo/grc20/v0"
gno = "0.9"

[addpkg]
  creator = "g1manfred47kzduec920z88wfr64ylksmdcedlf5"
  height = 26337
  max_deposit = "100000000ugnot"