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.

Function

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