Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v2 source realm

Package goldenticket is a 1/1 GRC721 NFT: one golden ticket, minted to the publisher when the package is added. It ch...

Overview

Package goldenticket is a 1/1 GRC721 NFT: one golden ticket, minted to the publisher when the package is added. It checks that a gno.land collection shows in the Adena wallet, built the way gnofly's planes are:

  • the collection is a gno.land/p/nt/grc721/v0 token made with NewToken, whose NewToken and Transfer events Adena finds on its indexer;
  • the read functions take a grc721.TokenID and return (value, error), as Adena calls them: OwnerOf("1"), BalanceOf("g1..."), TokenURI("1") as the <img src>, TokenMetadata("1") as JSON with camelCase traitType.

v2 of goldenticket: the image is no longer a constant. The publisher is the admin and moves it with SetImage, as the planes' SetImageBase does, so it can live where both Adena (any https: image) and gno.land's pages (an allowlist: GitHub, imgur, IPFS) load it.

Transfer moves the ticket, so it can reach any Adena account.

Variables 1

var Token, ledger, admin, image

1var (
2	// Token is the collection, read-only: Token.OwnerOf("1"), Token.BalanceOf.
3	Token  *grc721.Token
4	ledger *grc721.PrivateLedger
5
6	admin address // the publisher: the only one who sets the image
7	image string  // what TokenURI returns, and Render and TokenMetadata show
8)
source

Functions 9

func BalanceOf

Action
1func BalanceOf(addr address) (int64, error)
source

BalanceOf returns 1 for the holder of the ticket, 0 for everyone else.

func Name

Action
1func Name() string
source

Name and Symbol, as GRC721 tokens have them. Adena reads both from the NewToken event.

func Render

1func Render(_ string) string
source

Render shows the ticket and who holds it.

func SetImage

crossing Action
1func SetImage(cur realm, url string)
source

SetImage points the ticket at another image, at once: TokenURI is computed on every read. Admin only, by a direct call.

func TokenMetadata

Action
1func TokenMetadata(tid grc721.TokenID) (string, error)
source

TokenMetadata returns the metadata of the ticket as JSON, with the keys Adena reads.

func TokenURI

Action
1func TokenURI(tid grc721.TokenID) (string, error)
source

TokenURI returns the image of the ticket: what Adena shows.

func Transfer

crossing Action
1func Transfer(cur realm, to address)
source

Transfer gives the ticket to someone else. Only its holder can, by a direct call (maketx call or Adena), not through another realm.

Imports 3

Source Files 3