Skip to main content

ERC721

This interface is currently support by the NFT Collection and NFT Drop contracts. You can access all of its functions through an NFT Collection or NFT Drop contract instance.

type ERC721 struct {}

func (*ERC721) Balance

func (erc721 *ERC721) Balance() (int, error)

Get the NFT balance of the connected wallet.

returns: the number of NFTs on this contract owned by the connected wallet

func (*ERC721) BalanceOf

func (erc721 *ERC721) BalanceOf(address string) (int, error)

Get the NFT balance of a specific wallet.

address: the address of the wallet to get the NFT balance of

returns: the number of NFTs on this contract owned by the specified wallet

Example

address := "{{wallet_address}}"
balance, err := contract.BalanceOf(address)

func (*ERC721) Burn

func (erc721 *ERC721) Burn(tokenId int) (*types.Transaction, error)

Burn a specified NFT from the connected wallet.

tokenId: tokenID of the token to burn

returns: the transaction receipt of the burn

Example

tokenId := 0
tx, err := contract.Burn(tokenId)

func (*ERC721) Get

func (erc721 *ERC721) Get(tokenId int) (*NFTMetadataOwner, error)

Get metadata for a token.

tokenId: token ID of the token to get the metadata for

returns: the metadata for the NFT and its owner

Example

nft, err := contract.Get(0)

owner := nft.Owner name := nft.Metadata.Name

func (*ERC721) GetAll

func (erc721 *ERC721) GetAll() ([]*NFTMetadataOwner, error)

Get the metadata of all the NFTs on this contract.

returns: the metadata of all the NFTs on this contract

Example

nfts, err := contract.GetAll()
ownerOne := nfts[0].Owner
nameOne := nfts[0].Metadata.Name

func (*ERC721) GetTotalCount

func (erc721 *ERC721) GetTotalCount() (int, error)

Get the total number of NFTs on this contract.

returns: the total number of NFTs on this contract

func (*ERC721) IsApproved

func (erc721 *ERC721) IsApproved(address string, operator string) (bool, error)

Check whether an operator address is approved for all operations of a specifc addresses assets.

address: the address whose assets are to be checked

operator: the address of the operator to check

returns: true if the operator is approved for all operations of the assets, otherwise false

func (*ERC721) OwnerOf

func (erc721 *ERC721) OwnerOf(tokenId int) (string, error)

Get the owner of an NFT.

tokenId: the token ID of the NFT to get the owner of

returns: the owner of the NFT

func (*ERC721) SetApprovalForAll

func (erc721 *ERC721) SetApprovalForAll(operator string, approved bool) (*types.Transaction, error)

Set the approval for all operations of a specific address's assets.

address: the address whose assets are to be approved

operator: the address of the operator to set the approval for

approved: true if the operator is approved for all operations of the assets, otherwise false

returns: the transaction receipt of the approval

func (*ERC721) SetApprovalForToken

func (erc721 *ERC721) SetApprovalForToken(operator string, tokenId int) (*types.Transaction, error)

Approve an operator for the NFT owner, which allows the operator to call transferFrom or safeTransferFrom for the specified token.

operator: the address of the operator to approve

tokenId: the token ID of the NFT to approve

returns: the transaction receipt of the approval

func (*ERC721) TotalSupply

func (erc721 *ERC721) TotalSupply() (int, error)

Get the total number of NFTs on this contract.

returns: the supply of NFTs on this contract

func (*ERC721) Transfer

func (erc721 *ERC721) Transfer(to string, tokenId int) (*types.Transaction, error)

Transfer a specified token from the connected wallet to a specified address.

to: wallet address to transfer the tokens to

tokenId: the token ID of the NFT to transfer

returns: the transaction of the NFT transfer

Example

to := "0x..."
tokenId := 0

tx, err := contract.Transfer(to, tokenId)