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

planes package

Overview

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

Package planes is a collection of 777 plane NFTs that pilots fly in gnofly, a multiplayer plane game. It is a GRC721 token built on gno.land/p/nt/grc721/v0 with the royalty extension.

Every plane is drawn in a table committed with the realm (table.gno): a name, one of the nine models the game client draws, a pilot (none or a gnome), three colours, a tier and the colour of its laser, the shots every pilot sees it fire. The designs stay procedural in the client; the token stores only these traits. Id 777 is the super-gnome, a 1/1 that is a gnome flying like a superhero rather than a plane. The table is public; which ids a mint gets is drawn at random among the ones left, 1 to 7 per call (draw.gno).

Three kinds of callers write to it:

  • anyone mints the next plane with the price attached (Mint), transfers, approves and burns their planes (TransferFrom, Approve, SetApprovalForAll, Burn);
  • the admins of the game realm open and close the mint and tune its price, its per-wallet cap, the image URL and the royalty (SetMintOpen, SetPrice, SetMintCap, SetImageBase, SetRoyaltyBps);
  • nobody else: there is no reserve and no airdrop.

The realm keeps no roles and no money of its own. The admins are those of gno.land/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/game/v0, asked at the time of each call, and every mint is forwarded to its treasury in the same transaction. The royalty of a resale, 5% by default, names the treasury too.

Reads are plain functions meant for vm/qeval. The ones ending in JSON return a single string holding a JSON document. PlanesOf and OwnerOf are what the game server reads: ownership is the only on-chain fact of a plane, which one a pilot flies is picked in the game's hangar and checked against OwnerOf by the server. Render exposes the same data as markdown for gnoweb. The read side of the token and of its royalty extension is exported as Token and Royalties, for other realms. No metadata is stored per token: TokenMetadata and TokenURI are computed from the table and the image base on every read.

Storage is paid for at deploy, so the realm is kept small: the table is one string read in place, refusals are string constants, and the settings are read through CollectionJSON rather than one getter each.

Functions

Approve

func Approve(cur realm, to address, id int64)

Approve lets to move plane id once. The caller must own it. An empty address revokes.

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/planes" -func "Approve" -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/planes" -func "Approve" -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
  

BalanceOf

func BalanceOf(addr address) (int64, error)

BalanceOf returns how many planes addr owns.

Param

Command

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

Result

Burn

func Burn(cur realm, id int64)

Burn destroys a plane. Only its owner can, and nobody can mint it again: the id stays out of circulation.

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/planes" -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/planes" -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
  

CollectionJSON

func CollectionJSON() string

CollectionJSON returns the state of the collection as one JSON object:

Example
1{ "name": "gnofly planes", "symbol": "PLANE",
2  "supply": 777, "minted": 12, "burned": 0,
3  "price": 77000000, "open": true, "cap": 7,
4  "royaltyBps": 500, "treasury": "g1...",
5  "imageBase": "https://gnofly.xyz/nft/collections/planes/",
6  "tiers": { "common": { "supply": 500, "minted": 8 },
7             "rare": { "supply": 200, "minted": 3 },
8             "epic": { "supply": 70, "minted": 1 },
9             "legendary": { "supply": 7, "minted": 0 } } }

The output has no whitespace. "minted" counts every mint so far, burned planes included; "minted" minus "burned" is what exists.

Command

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

Result

IsApprovedForAll

func IsApprovedForAll(owner, operator address) bool

IsApprovedForAll reports whether operator may move every plane of owner.

Params

Command

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

Result

Mint

func Mint(cur realm, count int64) []int64

Mint mints count planes for the caller, 1 to 7 in one call, drawn at random among the ids not minted yet (draw.gno), and returns their ids in the order drawn. Exactly count times the price must be attached to the transaction (-send "<count*price>ugnot"); it is forwarded to the treasury of the game realm, in one send, before the call returns.

Each id comes out once, while the mint is open. A batch is minted whole or not at all: one that would take the caller over the per-wallet cap, or past the last plane, is refused with how many are left. It must be called directly by a user (maketx call): a call relayed by another realm or by a maketx run script is refused. That is also what keeps the draw fair: a contract could otherwise look at the ids it got and panic to draw again.

The caller pays the storage of their planes as a deposit on top of the price, given back on burn: the ledger entries only, the traits stay in the table (see the numbers in docs/spec.md, section 9.2).

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/planes" -func "Mint" -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/planes" -func "Mint" -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
  

Minted

func Minted() int64

Minted returns how many planes were minted so far, burned ones included. Planes are drawn at random, so it says nothing of which ids. The settings (price, open, cap, image base, royalty) are read with CollectionJSON: every exported function costs storage at deploy, measured at about 650 bytes each, so there is no getter per setting.

Command

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

Result

MintedJSON

func MintedJSON(offset, limit int64) string

MintedJSON returns who owns the minted planes among the ids offset+1 to offset+limit, as a JSON array in id order:

Example
1[{"id":3,"owner":"g1..."},{"id":42,"owner":""},...]

Ids not minted are left out; "owner" is "" for a burned plane. limit is capped at 200, so four calls (offsets 0, 200, 400, 600) cover the 777, whatever was minted: planes are drawn at random, minted ids are not a prefix. It is what the website's grid reads. An empty range is [].

Params

Command

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

Result

PlaneJSON

func PlaneJSON(id int64) string

PlaneJSON returns one plane as a JSON object, minted or not:

Example
1{ "id": 42, "name": "Storm Saint", "model": "delta", "pilot": "gnome",
2  "body": "#1e1b4b", "wing": "#1e293b", "accent": "#00f5ff", "tier": "epic",
3  "laser": "#39ff14", "image": "https://gnofly.xyz/nft/collections/planes/042.png", "owner": "g1..." }

The output has no whitespace. "owner" is "" for a plane not minted, or burned. An id outside 1 to 777 returns "". Which plane a pilot flies is not on-chain: the game server checks the owner when a pilot picks one.

Param

Command

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

Result

PlanesOf

func PlanesOf(addr address) string

PlanesOf returns the ids of the planes addr owns as a JSON array, in ascending order: [3,42,700]. It is [] for an address without planes.

Param

Command

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

Result

Render

func Render(path string) string

Render returns the state of the collection as markdown, for gnoweb:

Example
1""               the collection: minted, price, tiers, the last mints
2"plane/<id>"     one plane: traits, owner
3"player/<addr>"  the planes of one address

Everything printed here is a row of the table, whose charset the tests pin, a setting validated when it was written, or an address the chain gave the realm. The two caller-supplied values, an id and an address, are printed only once parsed and found valid. Nothing needs markdown escaping. No images: the planes are drawn by the game and by the website.

Param

Command

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

Result

RoyaltyBps

func RoyaltyBps() int64

RoyaltyBps returns the royalty of a resale, in basis points.

Command

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

Result

SetApprovalForAll

func SetApprovalForAll(cur realm, operator address, approved bool)

SetApprovalForAll lets operator move every plane of the caller, or revokes it.

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/planes" -func "SetApprovalForAll" -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/planes" -func "SetApprovalForAll" -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
  

SetImageBase

func SetImageBase(cur realm, base string)

SetImageBase sets where the images and the metadata of the planes are served from: the image of plane 42 is <base>042.png and its token URI is <base>42.json. Admin only.

It applies at once to every plane: the URLs are computed on read, nothing is stored per token.

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/planes" -func "SetImageBase" -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/planes" -func "SetImageBase" -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
  

SetMintCap

func SetMintCap(cur realm, n int64)

SetMintCap sets how many planes one wallet may mint over its lifetime, from 1 to 777. Admin only. A wallet already over a lowered cap keeps its planes and mints no more.

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/planes" -func "SetMintCap" -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/planes" -func "SetMintCap" -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
  

SetMintOpen

func SetMintOpen(cur realm, open bool)

SetMintOpen opens or closes the mint. Admin only. The mint starts closed.

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/planes" -func "SetMintOpen" -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/planes" -func "SetMintOpen" -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
  

SetPrice

func SetPrice(cur realm, ugnot int64)

SetPrice sets what a mint costs, from 1 to 10000 GNOT. Admin only. It applies to the next mint.

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/planes" -func "SetPrice" -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/planes" -func "SetPrice" -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
  

SetRoyaltyBps

func SetRoyaltyBps(cur realm, bps int64)

SetRoyaltyBps sets the royalty of a resale, from 0 to 1000 basis points, and points it at the treasury of the game realm as it is now. Admin only.

The royalty is advisory, as EIP-2981 is: a marketplace reads RoyaltyInfo and pays it, the realm cannot enforce it on a transfer.

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/planes" -func "SetRoyaltyBps" -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/planes" -func "SetRoyaltyBps" -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
  

TokenMetadata

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

TokenMetadata returns the metadata of a minted plane as JSON, built from the table on every read: the realm stores no metadata per token.

Example
1{"name":"Storm Saint","description":"Plane 42 of 777, ...",
2 "image":"https://gnofly.xyz/nft/collections/planes/042.png",
3 "attributes":[{"traitType":"model","value":"delta"}, ...]}

The keys are the ones Adena reads, traitType included.

Param

Command

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

Result

TokenURI

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

TokenURI returns the image of a minted plane, "<image base><nnn>.png": what a wallet shows (Adena puts it in an <img>). The metadata is TokenMetadata, or "<image base><id>.json" on the website. It is computed, not stored: a mint writes no URI.

Param

Command

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

Result

TotalSupply

func TotalSupply() int64

TotalSupply returns how many planes exist: minted and not burned.

Command

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

Result

TransferFrom

func TransferFrom(cur realm, from, to address, id int64)

TransferFrom moves plane id from one address to another. The caller must own it or be approved for it.

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/planes" -func "TransferFrom" -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/planes" -func "TransferFrom" -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