nft

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package nft provides base functionality for interacting with NFTs using the IERC721 standard.

Package nft provides base functionality for interacting with NFTs using the IERC721 standard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseError

func ParseError(rawErr any) error

ParseError parses raw contract errors into human-readable error messages for NFT/ERC721 operations.

Types

type BaseNFTSignature

type BaseNFTSignature string

BaseNFTSignature represents function signatures for basic NFT operations

const (
	// Name represents the name function signature
	Name BaseNFTSignature = "name()"
	// Symbol represents the symbol function signature
	Symbol BaseNFTSignature = "symbol()"
	// BalanceOf represents the balanceOf function signature
	BalanceOf BaseNFTSignature = "balanceOf(address)"
	// TotalSupply represents the totalSupply function signature
	TotalSupply BaseNFTSignature = "totalSupply()"
	// OwnerOf represents the ownerOf function signature
	OwnerOf BaseNFTSignature = "ownerOf(uint256)"
	// TokenURI represents the tokenURI function signature
	TokenURI BaseNFTSignature = "tokenURI(uint256)" // #nosec G101
	// Approve represents the approve function signature
	Approve BaseNFTSignature = "approve(address,uint256)"
	// GetApproved represents the getApproved function signature
	GetApproved BaseNFTSignature = "getApproved(uint256)"
	// TransferFrom represents the transferFrom function signature
	TransferFrom BaseNFTSignature = "transferFrom(address,address,uint256)"
	// SafeTransferFrom represents the safeTransferFrom function signature
	SafeTransferFrom BaseNFTSignature = "safeTransferFrom(address,address,uint256)"
)

func (BaseNFTSignature) GetHex

func (s BaseNFTSignature) GetHex() string

GetHex returns the hex representation of the function signature

func (BaseNFTSignature) GetSelector

func (s BaseNFTSignature) GetSelector() []byte

GetSelector returns the Keccak256 hash selector for the base NFT signature

func (BaseNFTSignature) String

func (s BaseNFTSignature) String() string

type ERC721Interactions

type ERC721Interactions struct {
	*base.Interactions
	// contains filtered or unexported fields
}

ERC721Interactions provides methods for interacting with ERC721 NFT contracts

func NewERC721Interactions

func NewERC721Interactions(
	baseInteractions *base.Interactions,
	address common.Address,
	signatures []BaseNFTSignature,
	transactOps ...*bind.TransactOpts,
) (*ERC721Interactions, error)

NewERC721Interactions creates a new instance of ERC721Interactions from a base interaction interface and an NFT contract address.

func (*ERC721Interactions) Approve

func (d *ERC721Interactions) Approve(to common.Address, tokenID *big.Int) (*types.Transaction, error)

Approve approves an address to transfer a specific token.

func (*ERC721Interactions) BalanceOf

func (d *ERC721Interactions) BalanceOf(owner common.Address) (*big.Int, error)

BalanceOf retrieves the NFT balance for a given owner.

func (ERC721Interactions) CallOpts

func (s ERC721Interactions) CallOpts() *bind.CallOpts

func (*ERC721Interactions) GetAddress

func (d *ERC721Interactions) GetAddress() common.Address

GetAddress returns the NFT contract address.

func (*ERC721Interactions) GetApproved

func (d *ERC721Interactions) GetApproved(tokenID *big.Int) (common.Address, error)

GetApproved returns the approved address for a specific token.

func (*ERC721Interactions) GetBalance

func (d *ERC721Interactions) GetBalance() (*big.Int, error)

GetBalance retrieves the balance of NFTs for the associated address.

func (*ERC721Interactions) GetSession

func (d *ERC721Interactions) GetSession() transaction.Session

GetSession returns the current session used for NFT interactions.

func (ERC721Interactions) Instance

func (s ERC721Interactions) Instance() *bind.BoundContract

func (*ERC721Interactions) Name

func (d *ERC721Interactions) Name() (string, error)

Name returns the name of the NFT.

func (*ERC721Interactions) OwnerOf

func (d *ERC721Interactions) OwnerOf(tokenID *big.Int) (common.Address, error)

OwnerOf retrieves the owner of a specific token.

func (*ERC721Interactions) Symbol

func (d *ERC721Interactions) Symbol() (string, error)

Symbol returns the symbol of the NFT.

func (*ERC721Interactions) TokenMetaInfos

func (d *ERC721Interactions) TokenMetaInfos(tokenID *big.Int) (*models.TokenMeta, error)

TokenMetaInfos retrieves metadata about the specified token such as name, symbol, and URI.

func (*ERC721Interactions) TokenURI

func (d *ERC721Interactions) TokenURI(tokenID *big.Int) (string, error)

TokenURI returns the URI of the NFT.

func (*ERC721Interactions) TotalSupply

func (d *ERC721Interactions) TotalSupply() (*big.Int, error)

TotalSupply returns the total number of NFTs minted.

func (*ERC721Interactions) TransferFirstOwnedTo

func (d *ERC721Interactions) TransferFirstOwnedTo(to common.Address) (*types.Transaction, error)

TransferFirstOwnedTo transfers the first token owned by the signer to the specified address.

func (*ERC721Interactions) TransferTo

func (d *ERC721Interactions) TransferTo(to common.Address, tokenID *big.Int) (*types.Transaction, error)

TransferTo transfers a specific token to another address after verifying ownership.

Directories

Path Synopsis
Package enumerable provides functions to interact with ERC721 enumerable properties.
Package enumerable provides functions to interact with ERC721 enumerable properties.
Package royalties provides functions to interact with ERC721 royalty properties.
Package royalties provides functions to interact with ERC721 royalty properties.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL