Search Apps Documentation Source Content File Folder Download Copy Actions Download

nftmarket package

Overview

Package nftmarket is a multi-collection NFT marketplace realm for gno.land, in the spirit of OpenSea but built for GnoVM.

It bundles three capabilities in a single realm:

  1. Collection factory — any user can create their own NFT collection with CreateCollection and becomes its creator (royalty + mint-proceeds recipient).
  2. Open minting — any user can mint a token from any collection with Mint, paying the collection's mint price (which goes to the creator).
  3. Marketplace — a token owner lists an NFT for a fixed price with List, and anyone buys it with Buy. The sale price is split between the seller, the collection creator (royalty) and the platform (fee).

Why one realm instead of separate "nft" and "market" realms? In gno.land's GRC721 design, only the realm that holds the concrete *grc721.BasicNFT may move its tokens — across a realm boundary it exposes a read-only view (see p/demo/tokens/grc721/igrc721.gno). Keeping minting and the market in the same realm lets the market escrow and transfer sold NFTs internally, without fragile cross-realm approvals.

Payments use the native coin (ugnot). Buyers and minters attach coins to the call (gnokey ... -send "<amount>ugnot"); the realm escrows them and pays the recipients out via the banker. All amounts are in ugnot (1 GNOT = 1_000_000 ugnot).

Functions

Buy

func Buy(cur realm, collID, tokenID string)

Buy purchases a listed token. The caller must attach exactly the listing price in ugnot. The price is split: royalty -> collection creator, fee -> platform, remainder -> seller. The NFT is transferred to the buyer.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "Buy" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "Buy" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

CancelListing

func CancelListing(cur realm, collID, tokenID string)

CancelListing delists a token and returns it from escrow to the seller.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "CancelListing" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "CancelListing" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

ClaimAdmin

func ClaimAdmin(cur realm)

ClaimAdmin assigns the platform admin to the caller. It can only be called once (when no admin is set yet). Deployers should call this immediately after publishing the realm — ideally in the same deploy script — to avoid someone else claiming it first.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "ClaimAdmin" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "ClaimAdmin" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

CreateCollection

func CreateCollection(cur realm, id, name, symbol, baseURI string, mintPrice, maxSupply, royaltyBps int64) string

CreateCollection registers a new NFT collection owned by the caller and returns its id. mintPrice and maxSupply may be 0 (free / unlimited). royaltyBps is the creator's cut of every future secondary sale (0..5000).

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "CreateCollection" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "CreateCollection" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

FeeBps

func FeeBps() int64

FeeBps returns the current platform fee in basis points.

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket.FeeBps()"

Result

FeePot

func FeePot() int64

FeePot returns the amount of ugnot currently withdrawable as platform fees.

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket.FeePot()"

Result

List

func List(cur realm, collID, tokenID string, price int64)

List puts a token the caller owns up for sale at a fixed price (in ugnot). The NFT is escrowed in the realm until the listing is bought or cancelled.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "List" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "List" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

Mint

func Mint(cur realm, collID string) string

Mint mints the next token of a collection to the caller, who must attach exactly the collection's mint price in ugnot. The proceeds go to the collection creator. Returns the newly minted token id.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "Mint" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

Render

func Render(path string) string

Render renders the realm as Markdown for the gno.land web UI.

Example
1""                     -> marketplace home (collections + recent listings)
2"collection/<id>"      -> a single collection and its active listings
3"listings"             -> every active listing

Param

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket.Render()"

Result

SetAdmin

func SetAdmin(cur realm, newAdmin address)

SetAdmin transfers the platform admin role to newAdmin. Admin only.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "SetAdmin" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "SetAdmin" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

SetFeeBps

func SetFeeBps(cur realm, bps int64)

SetFeeBps sets the platform fee charged on secondary sales, in basis points (e.g. 250 = 2.5%). Capped at maxFeeBps. Admin only.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "SetFeeBps" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "SetFeeBps" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

TokenURI

func TokenURI(collID, tokenID string) string

TokenURI returns the metadata URI for a token (baseURI + tokenID).

Params

Command

gnokey query vm/qeval -remote "https://rpc.test13.testnets.gno.land" -data "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket.TokenURI(,)"

Result

UpdatePrice

func UpdatePrice(cur realm, collID, tokenID string, newPrice int64)

UpdatePrice changes the asking price of an active listing. Seller 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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "UpdatePrice" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "UpdatePrice" -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 "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx
  

WithdrawFees

func WithdrawFees(cur realm, addr address) int64

WithdrawFees sends all accrued platform fees to addr and returns the amount. Admin only.

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/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "WithdrawFees" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "test-13" -remote "https://rpc.test13.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test13.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g18wk4a80cr7dqa25vfka2yug5n3pd50udled6y3/nftmarket" -func "WithdrawFees" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test-13" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test13.testnets.gno.land" call.tx