func Approve
crossing ActionApprove 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.
Package gnft implements GRC721-compliant NFTs for GnoSwap LP positions.
GRC721-compliant NFT contract for GnoSwap LP positions.
GNFT represents each liquidity position as a unique NFT with dynamically generated SVG artwork. Each NFT features a gradient background with parameters stored efficiently to minimize gas costs.
MintMints new NFT for LP position.
Parameters:
cur realm: Current realm contextto address: Recipient addresstid grc721.TokenID: Token ID to mintReturns: grc721.TokenID
BurnBurns NFT when position is closed.
Parameters:
cur realm: Current realm contexttid grc721.TokenID: Token ID to burnTransferFromTransfers NFT ownership.
Parameters:
cur realm: Current realm contextfrom address: Current ownerto address: New ownertid grc721.TokenID: Token ID to transferTokenURIReturns the token URI, rendering stored SVG parameters as a base64 image data URI.
Parameters:
tid grc721.TokenID: Token IDReturns: Token URI string, using a base64-encoded SVG data URI for generated GNFT images
ApproveApproves address to manage specific token.
Parameters:
cur realm: Current realm contextto address: Address to approvetid grc721.TokenID: Token IDSetApprovalForAllApproves operator to manage all tokens.
Parameters:
cur realm: Current realm contextoperator address: Operator addressapproved bool: Approval statusToken URI stores compact parameters:
"x1,y1,x2,y2,#COLOR1,#COLOR2"
Example: "10,12,125,123,#FF5733,#33B5FF"
1<svg width="135" height="135">
2 <circle cx="67.5" cy="67.5" r="67.5" fill="url(#gradient)"/>
3 <!-- GnoSwap logo paths -->
4 <linearGradient id="gradient" x1="X1" y1="Y1" x2="X2" y2="Y2">
5 <stop stop-color="#COLOR1"/>
6 <stop offset="1" stop-color="#COLOR2"/>
7 </linearGradient>
8</svg>
1// Position contract mints NFT when creating position
2import "gno.land/r/gnoswap/gnft"
3
4// Mint NFT for new position
5tokenId := gnft.Mint(cross(cur), ownerAddress, positionId)
6
7// Get token URI with SVG
8imageURI, err := gnft.TokenURI(tokenId)
9// Returns: "data:image/svg+xml;base64,..." for generated GNFT images
10
11// Transfer NFT
12gnft.TransferFrom(cross(cur), fromAddress, toAddress, tokenId)
13
14// Burn NFT when closing position
15gnft.Burn(cross(cur), tokenId)
gno.land/p/demo/tokens/grc721: GRC721 implementationgno.land/r/gnoswap/rbac: Access controlgno.land/r/gnoswap/access: Position role mirrornft: GRC721 token instanceowner.AssertOwnedByPrevious(): Checks that the caller owns the GNFT before owner-only operationscheckErr(): Panic on errorsPackage 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.
Approve grants permission to transfer a specific token ID to another address.
Parameters:
Returns error if approval fails.
BalanceOf returns the number of NFTs owned by the specified address.
Burn removes a specific token ID.
Parameters:
Only callable by position.
Exists checks if token ID exists.
IsApprovedForAll checks if operator can manage all owner's tokens.
Parameters:
Returns true if operator is approved for all owner's tokens.
Mint creates new NFT and transfers to address.
Parameters:
Returns minted token ID. Only callable by position contract.
Name returns the NFT collection name.
Render returns the HTML representation of the NFT.
SafeTransferFrom transfers token ownership with receiver validation.
Parameters:
Returns error if transfer fails.
Permission model:
SetApprovalForAll enables/disables operator approval for all tokens.
Parameters:
Returns error if operation fails.
SetTokenURI sets the metadata URI for the specified token.
Parameters:
Only callable by position contract.
Symbol returns the NFT symbol.
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.
TotalSupply returns the total number of NFTs minted.
TransferFrom transfers a token from one address to another.
Parameters:
Returns error if transfer fails.
Permission model: