func BalanceOf
ActionBalanceOf returns how many skin tokens addr owns, one per design at most.
v0 - Unaudited: This is an initial version that has not yet been formally audited. Use in production at your own risk.
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:
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.
BalanceOf returns how many skin tokens addr owns, one per design at most.
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.
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.
CatalogJSON returns every design, sorted by id, as a JSON array:
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.
Render returns the shop as markdown, for gnoweb:
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.
1func SetSkin(cur realm, id, name, model, pilot, body, wing, accent string, price, maxSupply int64)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.
SetSkinListed puts a design on or off sale. Admin only.
SkinOf returns the design of skin token id, "" when there is no such token.
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.
TokenMetadata returns the metadata of skin token tid as JSON, the same for every token of a design, with the keys Adena reads:
TokenURI returns the image of skin token tid, "https://gnofly.xyz/nft/skins/<design>.png": what a wallet shows (Adena puts it in an <img>). The metadata is TokenMetadata, or "https://gnofly.xyz/nft/skins/<design>.json" on the website. It is computed, not stored: a token costs no URI in deposit.