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 package

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

BalanceOf

func BalanceOf(addr address) (int64, error)

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

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.BalanceOf()"

Result

Burn

func Burn(cur realm, id int64)

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.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "Burn" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "Burn" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Buy

func Buy(cur realm, skinID string) int64

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.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "Buy" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "Buy" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

CatalogJSON

func CatalogJSON() string

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.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.CatalogJSON()"

Result

Render

func Render(path string) string

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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.Render()"

Result

SetSkin

func 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.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "SetSkin" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "SetSkin" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

SetSkinListed

func SetSkinListed(cur realm, id string, listed bool)

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "SetSkinListed" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins" -func "SetSkinListed" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

SkinOf

func SkinOf(id int64) string

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

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.SkinOf()"

Result

SkinsOf

func SkinsOf(addr address) string

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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.SkinsOf()"

Result

TokenMetadata

func TokenMetadata(tid grc721.TokenID) (string, error)

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"}, ...]}

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.TokenMetadata()"

Result

TokenURI

func TokenURI(tid grc721.TokenID) (string, error)

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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/nfts/skins.TokenURI()"

Result