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 source realm

Package gnft implements GRC721-compliant NFTs for GnoSwap LP positions.

Overview

Package gnft implements GRC721-compliant NFTs for GnoSwap LP positions.

Each LP position in GnoSwap is represented as a unique NFT with dynamically generated SVG artwork. The contract manages ownership, transfers, and visual representation of positions while minimizing storage costs.

Functions 15

func Approve

crossing Action
1func Approve(cur realm, approved address, tid grc721.TokenID) error
source

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

Parameters:

  • approved: address to approve
  • tid: token ID to approve for transfer

Returns error if approval fails.

func BalanceOf

Action
1func BalanceOf(owner address) (int64, error)
source

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

func Burn

crossing Action
1func Burn(cur realm, tid grc721.TokenID)
source

Burn removes a specific token ID.

Parameters:

  • tid: token ID to burn

Only callable by position.

func IsApprovedForAll

Action
1func IsApprovedForAll(owner, operator address) bool
source

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

Parameters:

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

Returns true if operator is approved for all owner's tokens.

func Mint

crossing Action
1func Mint(cur realm, to address, tid grc721.TokenID) grc721.TokenID
source

Mint creates new NFT and transfers to address.

Parameters:

  • to: recipient address
  • tid: token ID

Returns minted token ID. Only callable by position contract.

func Render

1func Render(path string) string
source

Render returns the HTML representation of the NFT.

func SafeTransferFrom

crossing Action
1func SafeTransferFrom(cur realm, from, to address, tid grc721.TokenID) error
source

SafeTransferFrom transfers token ownership with receiver validation.

Parameters:

  • from: current owner address
  • to: recipient address
  • tid: token ID to transfer

Returns error if transfer fails.

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

func SetApprovalForAll

crossing Action
1func SetApprovalForAll(cur realm, operator address, approved bool) error
source

SetApprovalForAll enables/disables operator approval for all tokens.

Parameters:

  • operator: address to set approval for
  • approved: true to approve, false to revoke

Returns error if operation fails.

func SetTokenURI

crossing Action
1func SetTokenURI(cur realm, tid grc721.TokenID, tURI grc721.TokenURI) (bool, error)
source

SetTokenURI sets the metadata URI for the specified token.

Parameters:

  • tid: token ID
  • tURI: token URI

Only callable by position contract.

func TokenURI

Action
1func TokenURI(tid grc721.TokenID) (string, error)
source

TokenURI returns the metadata URI for the specified token ID. If stored value is in parameter format (x1,y1,x2,y2,color1,color2), it converts to full base64-encoded SVG image URI on read.

func TransferFrom

crossing Action
1func TransferFrom(cur realm, from, to address, tid grc721.TokenID) error
source

TransferFrom transfers a token from one address to another.

Parameters:

  • from: current owner address
  • to: recipient address
  • tid: token ID

Returns error if transfer fails.

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

Types 1

type ImageParams

struct
1type ImageParams struct {
2	x1, y1, x2, y2 int
3	color1, color2 string
4}
source

ImageParams holds parsed and validated image parameters.

Imports 12

Source Files 7