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.

stamps.gno

0.89 Kb · 41 lines
 1// An independent, freely mintable test collection with no creator royalty.
 2package tavern_stamps
 3
 4import (
 5	"gno.land/p/nt/grc721/v0"
 6	"strconv"
 7)
 8
 9var token *grc721.Token
10var ledger *grc721.PrivateLedger
11var teller grc721.Teller
12
13func init(cur realm) {
14	token, ledger = grc721.NewToken("Tavern Stamps", "STAMP", 0, cur)
15	teller = ledger.CallerTeller()
16}
17
18func Claim(cur realm) string {
19	id := strconv.FormatInt(token.TotalSupply()+1, 10)
20	if err := ledger.Mint(cur.Previous().Address(), grc721.TokenID(id)); err != nil {
21		panic(err)
22	}
23	return id
24}
25
26func OwnerOf(id string) address {
27	owner, err := token.OwnerOf(grc721.TokenID(id))
28	if err != nil {
29		panic(err)
30	}
31	return owner
32}
33
34func TransferFrom(cur realm, from, to address, id string) {
35	if cur.Previous().Address() != from {
36		panic("owner required")
37	}
38	if err := teller.TransferFrom(0, cur, from, to, grc721.TokenID(id)); err != nil {
39		panic(err)
40	}
41}