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

gnft package

Overview

Package gnft implements the position-NFT surface used by GnoSwap.

It provides GRC721-compatible ownership, transfer, approval, and metadata operations for LP positions. Generated parameter-format URIs become SVG data URIs on read; custom non-empty URIs are returned unchanged. Enumeration and safeTransferFrom are not exposed by this package.

Functions

Approve

func Approve(cur realm, approved address, tid grc721.TokenID) error

Approve grants permission to transfer a specific token ID to another address.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • approved: address to approve
  • tid: token ID to approve for transfer

Returns:

  • error: nil after approval is stored; invalid addresses, ownership, or ledger failures panic through checkApproveErr

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/gnoswap/gnft" -func "Approve" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gnft" -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 "http://127.0.0.1:26657" call.tx
  

BalanceOf

func BalanceOf(owner address) (int64, error)

BalanceOf returns the number of NFTs owned by the specified address.

Parameters:

  • owner: address whose NFT balance is queried

Returns:

  • balance: number of NFTs owned by owner
  • error: token-ledger balance lookup error; an invalid owner address panics before the lookup

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.BalanceOf()"

Result

Burn

func Burn(cur realm, tid grc721.TokenID)

Burn removes a specific token ID.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • tid: token ID to burn

Only callable by position.

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/gnoswap/gnft" -func "Burn" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gnft" -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 "http://127.0.0.1:26657" call.tx
  

Exists

func Exists(tid grc721.TokenID) bool

Exists checks if token ID exists.

Parameters:

  • tid: token ID to check

Returns:

  • exists: true when the ledger can resolve an owner for tid; false otherwise

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.Exists()"

Result

IsApprovedForAll

func IsApprovedForAll(owner, operator address) bool

IsApprovedForAll checks if operator can manage all owner's tokens.

Parameters:

  • owner: token owner address
  • operator: operator address to check

Returns:

  • approved: true when operator is approved for every token owned by owner

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.IsApprovedForAll(,)"

Result

Mint

func Mint(cur realm, to address, tid grc721.TokenID) grc721.TokenID

Mint creates new NFT and transfers it to to.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • to: recipient address
  • tid: token ID to mint

Returns:

  • tokenID: minted token ID

Only callable by position contract.

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/gnoswap/gnft" -func "Mint" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gnft" -func "Mint" -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 "http://127.0.0.1:26657" call.tx
  

Name

func Name() string

Name returns the NFT collection name.

Returns:

  • name: collection name

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.Name()"

Result

Render

func Render(path string) string

Render returns the HTML representation of the NFT.

Parameters:

  • path: render path; the empty path selects the collection home page

Returns:

  • html: collection HTML for the home path, or "404\n" for unsupported paths

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.Render()"

Result

SetApprovalForAll

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

SetApprovalForAll enables/disables operator approval for all tokens.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • operator: address to set approval for
  • approved: true to approve, false to revoke

Returns:

  • error: nil after the operator approval is stored; ledger failures panic before a non-nil error can be returned

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/gnoswap/gnft" -func "SetApprovalForAll" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gnft" -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 "http://127.0.0.1:26657" call.tx
  

SetTokenURI

func SetTokenURI(cur realm, tid grc721.TokenID, tURI string) (bool, error)

SetTokenURI sets the metadata URI for the specified token.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • tid: token ID whose metadata URI is replaced
  • tURI: non-empty metadata URI or parameter-format image description

Returns:

  • updated: true after the URI is stored and re-read successfully
  • error: nil on success; validation and storage failures panic before a non-nil error can be returned

Only callable by position contract.

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/gnoswap/gnft" -func "SetTokenURI" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gnft" -func "SetTokenURI" -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 "http://127.0.0.1:26657" call.tx
  

Symbol

func Symbol() string

Symbol returns the NFT collection symbol.

Returns:

  • symbol: collection symbol

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.Symbol()"

Result

TokenURI

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

TokenURI returns the metadata URI for the specified token ID. Parameter-format values (x1,y1,x2,y2,color1,color2) are rendered as a base64-encoded SVG data URI; other non-empty stored URIs are returned unchanged.

Parameters:

  • tid: token ID whose metadata URI is requested

Returns:

  • uri: stored URI, or a generated SVG data URI for parameter-format metadata
  • error: metadata lookup error when tid has no retrievable metadata

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.TokenURI()"

Result

TotalSupply

func TotalSupply() int64

TotalSupply returns the total number of NFTs minted.

Returns:

  • supply: number of NFTs minted by the collection

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gnft.TotalSupply()"

Result

TransferFrom

func TransferFrom(cur realm, from, to address, tid grc721.TokenID) error

TransferFrom transfers a token from one address to another.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • from: current owner address
  • to: recipient address
  • tid: token ID to transfer

Returns:

  • error: nil after a successful transfer; invalid addresses, authorization, ownership, or ledger failures panic through checkTransferErr

Permission model:

  • Tokens held by the staker contract (i.e. currently staked) can only be moved by the staker itself; the underlying staked LP position is non-transferable.
  • Otherwise, ownership and approval are enforced by the GRC721 layer (owner / approved-for-token / approved-for-all).

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/gnoswap/gnft" -func "TransferFrom" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gnft" -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 "http://127.0.0.1:26657" call.tx