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

contract.gno

0.67 Kb · 27 lines
 1package grc20
 2
 3import (
 4	"chain/runtime/unsafe"
 5
 6	tokens "gno.land/p/nt/grc20/v0"
 7)
 8
 9// test1 receives the initial mint at construction.
10var test1 = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5")
11
12// Token is exported. Other contracts can read it (balances, metadata).
13// privateLedger stays unexported: it grants unrestricted mint/burn/transfer.
14var (
15	Token         *tokens.Token
16	privateLedger *tokens.PrivateLedger
17)
18
19func init(cur realm) {
20	// generate the token and mint some tokens to test1.
21	Token, privateLedger = tokens.NewToken("Foo Token", "FOO", 4, 0, cur)
22	privateLedger.Mint(test1, 100000000)
23}
24
25func MyBalance() int64 {
26	return Token.BalanceOf(unsafe.OriginCaller())
27}