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

skins source realm

v0 - Unaudited: This is an initial version that has not yet been formally audited. Use in production at your own risk.

Overview

v0 - Unaudited: This is an initial version that has not yet been formally audited. Use in production at your own risk.

Package skins is the catalog of plane skins of gnofly, a multiplayer plane game, and the tokens of the skins sold. Every skin bought is a GRC721 token on gno.land/p/nt/grc721/v0, one per buyer and design.

The tokens are soulbound: there is no TransferFrom, no Approve and no SetApprovalForAll, and the token object is not exported, so nothing can move a skin away from its buyer. Its owner can Burn it, which gives back the storage deposit (not the price).

Supply is unlimited by default; an admin can cap a design. Classic, the look every pilot flies by default, is free and is not a token.

Writers:

  • anyone buys a skin with its price attached (Buy), and burns their own (Burn);
  • the admins of the game realm edit the catalog (SetSkin, SetSkinListed).

The realm keeps no roles and no money: admins and treasury are those of gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0, and every sale is forwarded to the treasury in the same transaction.

A token stores only its owner (the ledger), its design and an entry in the buyer's list: no metadata record and no URI. TokenURI is computed from the design. Reads are plain functions meant for vm/qeval: CatalogJSON, SkinsOf, OwnerOf, SkinOf, TokenURI, Render.

Functions 11

func BalanceOf

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

BalanceOf returns how many skin tokens addr owns, one per design at most.

func Burn

crossing Action
1func Burn(cur realm, id int64)
source

Burn destroys a skin token. Only its owner can. The storage deposit paid at purchase comes back; the price does not. The owner can buy the design again, while it is listed.

func Buy

crossing Action
1func Buy(cur realm, skinID string) int64
source

Buy buys one token of a skin design for the caller and returns its id. The exact price must be attached to the transaction (-send "<price>ugnot") and is forwarded to the treasury of the game realm before the call returns.

An address owns at most one token of a design: a skin cannot be given away, so a second copy would be of no use. It must be called directly by a user (maketx call): a call relayed by another realm or by a maketx run script is refused.

func CatalogJSON

Action
1func CatalogJSON() string
source

CatalogJSON returns every design, sorted by id, as a JSON array:

Example
1[ { "id": "baron", "name": "Red Baron", "model": "biplane", "pilot": "none",
2    "body": "#c1121f", "wing": "#780000", "accent": "#fdf0d5",
3    "price": 1000000, "listed": true, "minted": 3, "maxSupply": 0 } ]

The output has no whitespace. maxSupply 0 is unlimited. Classic, the free look, is not in it: the client draws it without a token.

func Render

1func Render(path string) string
source

Render returns the shop as markdown, for gnoweb:

Example
1""               the catalog
2"skin/<id>"      one design
3"player/<addr>"  the skins of one address

Everything printed went through validate.gno when it was written, or is an address the chain gave the realm; the caller-supplied id and address are printed only once found valid.

func SetSkin

crossing Action
1func SetSkin(cur realm, id, name, model, pilot, body, wing, accent string, price, maxSupply int64)
source

SetSkin creates or updates a design. Admin only.

id is [a-z0-9-]{1,32} and not "classic", name [A-Za-z0-9 '.!-]{1,40}, model [a-z0-9-]{1,16}, pilot none or gnome, colours "#rrggbb" in lowercase, price 1 to 1e12 ugnot, maxSupply 0 for unlimited. A max supply under what is already minted stops the sales, it takes nothing back. Owners keep their tokens whatever happens to the design; its look is read from here, so a change of colours repaints every copy.

func SetSkinListed

crossing Action
1func SetSkinListed(cur realm, id string, listed bool)
source

SetSkinListed puts a design on or off sale. Admin only.

func SkinOf

Action
1func SkinOf(id int64) string
source

SkinOf returns the design of skin token id, "" when there is no such token.

func SkinsOf

Action
1func SkinsOf(addr address) string
source

SkinsOf returns the designs addr owns a token of, sorted by id, as a JSON array: ["baron","goldie"]. It is [] for an address without skins.

func TokenMetadata

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

TokenMetadata returns the metadata of skin token tid as JSON, the same for every token of a design, with the keys Adena reads:

Example
1{"name":"Red Baron","description":"A gnofly skin, a biplane. ...",
2 "image":"https://gnofly.xyz/nft/skins/baron.png",
3 "attributes":[{"traitType":"model","value":"biplane"}, ...]}

Imports 10

Source Files 10