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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

bbb.gno

1.49 Kb · 51 lines
 1// Package bbb is a throwaway GRC20 with an open faucet, used to exercise the
 2// pair instances in this repo. It has no value and no owner controls.
 3package bbb
 4
 5import (
 6	"gno.land/p/nt/grc20/v0"
 7	"gno.land/r/nt/grc20reg/v0"
 8)
 9
10var (
11	Token         *grc20.Token
12	privateLedger *grc20.PrivateLedger
13	userTeller    grc20.Teller
14)
15
16// Key is this token's grc20reg key, the string an instance realm is
17// configured with.
18const Key = "gno.land/r/moul/x/pairs/bbb/v0.BBB"
19
20func init(cur realm) {
21	Token, privateLedger = grc20.NewToken("Test Beta", "BBB", 6, 1, cur)
22	userTeller = privateLedger.CallerTeller()
23	grc20reg.Register(cross(cur), Token, "")
24}
25
26// Faucet mints a fixed amount to the caller. Unrestricted on purpose.
27func Faucet(cur realm) {
28	if err := privateLedger.Mint(cur.Previous().Address(), 1_000_000_000); err != nil {
29		panic(err)
30	}
31}
32
33func TotalSupply() int64                      { return userTeller.TotalSupply() }
34func BalanceOf(owner address) int64           { return userTeller.BalanceOf(owner) }
35func Allowance(owner, spender address) int64  { return userTeller.Allowance(owner, spender) }
36
37func Transfer(cur realm, to address, amount int64) {
38	if err := userTeller.Transfer(0, cur, to, amount); err != nil {
39		panic(err)
40	}
41}
42
43func Approve(cur realm, spender address, amount int64) {
44	if err := userTeller.Approve(0, cur, spender, amount); err != nil {
45		panic(err)
46	}
47}
48
49func Render(string) string {
50	return "# BBB\n\nThrowaway test token for the pair instances. `Faucet` mints 1000 BBB to you.\n"
51}