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 {
ClaimConditions *NFTDropClaimConditions
}

func (*ERC721) Balance

func (erc721 *ERC721) Balance(ctx context.Context) (int, error)

Get NFT balance

@extension: ERC721

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

Example

balance, err := contract.ERC721.Balance(context.Background())

func (*ERC721) BalanceOf

func (erc721 *ERC721) BalanceOf(ctx context.Context, address string) (int, error)

Get NFT balance of a specific wallet

@extension: ERC721

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.ERC721.BalanceOf(context.Background(), address)

func (*ERC721) Burn

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

Burna an NFT

@extension: ERC721Burnable

tokenId: tokenID of the token to burn

returns: the transaction receipt of the burn

Example

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

func (*ERC721) Claim

func (erc721 *ERC721) Claim(ctx context.Context, quantity int) (*types.Transaction, error)

Claim an NFT

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

quantity = 1
tx, err := contract.ERC721.Claim(context.Background(), quantity)

func (*ERC721) ClaimTo

func (erc721 *ERC721) ClaimTo(ctx context.Context, destinationAddress string, quantity int) (*types.Transaction, error)

Claim NFTs to a specific wallet

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

address := "{{wallet_address}}"
quantity = 1

tx, err := contract.ERC721.ClaimTo(context.Background(), address, quantity)

func (*ERC721) CreateBatch

func (erc721 *ERC721) CreateBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Lazy mint NFTs

@extension: ERC721LazyMintable

metadatas: a list of the metadatas of the NFTs to create

returns: the transaction receipt of the batch creation

Example

image0, err := os.Open("path/to/image/0.jpg")
defer image0.Close()

image1, err := os.Open("path/to/image/1.jpg")
defer image1.Close()

metadatas := []*thirdweb.NFTMetadataInput{
&thirdweb.NFTMetadataInput{
Name: "Cool NFT",
Description: "This is a cool NFT",
Image: image1
}
&thirdweb.NFTMetadataInput{
Name: "Cool NFT 2",
Description: "This is also a cool NFT",
Image: image2
}
}

tx, err := contract.ERC721.CreateBatch(context.Background(), metadatas)

func (*ERC721) Get

func (erc721 *ERC721) Get(ctx context.Context, tokenId int) (*NFTMetadataOwner, error)

Get an NFT

@extension: ERC721

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

returns: the metadata for the NFT and its owner

Example

nft, err := contract.ERC721.Get(context.Background(), 0)
owner := nft.Owner
name := nft.Metadata.Name

func (*ERC721) GetAll

func (erc721 *ERC721) GetAll(ctx context.Context) ([]*NFTMetadataOwner, error)

Get all NFTs

@extension: ERC721Supply | ERC721Enumerable

returns: the metadata of all the NFTs on this contract

Example

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

func (*ERC721) GetAllClaimed

func (erc721 *ERC721) GetAllClaimed(ctx context.Context) ([]*NFTMetadataOwner, error)

Get all claimed NFTs

returns: a list of the metadatas of the claimed NFTs

Example

claimedNfts, err := contract.ERC721.GetAllClaimed(context.Background())
firstOwner := claimedNfts[0].Owner

func (*ERC721) GetAllUnclaimed

func (erc721 *ERC721) GetAllUnclaimed(ctx context.Context) ([]*NFTMetadata, error)

Get all unclaimed NFTs

returns: a list of the metadatas of the unclaimed NFTs

Example

unclaimedNfts, err := contract.ERC721.GetAllUnclaimed(context.Background())
firstNftName := unclaimedNfts[0].Name

func (*ERC721) GetClaimArguments

func (erc721 *ERC721) GetClaimArguments(ctx context.Context, destinationAddress string, quantity int) (*ClaimArguments, error)

func (*ERC721) GetClaimIneligibilityReasons

func (erc721 *ERC721) GetClaimIneligibilityReasons(ctx context.Context, quantity int, addressToCheck string) ([]ClaimEligibility, error)

func (*ERC721) GetClaimInfo

func (erc721 *ERC721) GetClaimInfo(ctx context.Context, address string) (*ClaimInfo, error)

func (*ERC721) GetTotalCount

func (erc721 *ERC721) GetTotalCount(ctx context.Context) (int, error)

Get the total number of NFTs

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

returns: the total number of NFTs on this contract

Example

totalCount, err := contract.ERC721.GetTotalCount(context.Background())

func (*ERC721) IsApproved

func (erc721 *ERC721) IsApproved(ctx context.Context, owner string, operator string) (bool, error)

Check NFT approval

@extension: ERC721

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

Example

owner := "{{wallet_address}}"
operator := "0x..."

isApproved, err := contract.ERC721.IsApproved(ctx, owner, operator)

func (*ERC721) Mint

func (erc721 *ERC721) Mint(ctx context.Context, metadata *NFTMetadataInput) (*types.Transaction, error)

Mint an NFT

@extension: ERC721Mintable

metadata: metadata of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadata := &thirdweb.NFTMetadataInput{
Name: "Cool NFT",
Description: "This is a cool NFT",
Image: image,
}

tx, err := contract.ERC721.Mint(context.Background(), metadata)

func (*ERC721) MintBatch

func (erc721 *ERC721) MintBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Mint many NFTs

@extension: ERC721BatchMintable

metadatas: list of metadata of the NFTs to mint

returns: the transaction receipt of the mint

Example

metadatas := []*thirdweb.NFTMetadataInput{
&thirdweb.NFTMetadataInput{
Name: "Cool NFT",
Description: "This is a cool NFT",
}
&thirdweb.NFTMetadataInput{
Name: "Cool NFT 2",
Description: "This is also a cool NFT",
}
}

tx, err := contract.ERC721.MintBatchTo(context.Background(), metadatas)

func (*ERC721) MintBatchTo

func (erc721 *ERC721) MintBatchTo(ctx context.Context, address string, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Mint many NFTs to a specific wallet

@extension: ERC721BatchMintable

to: the wallet address to mint to

metadatas: list of metadata of the NFTs to mint

returns: the transaction receipt of the mint

Example

metadatas := []*thirdweb.NFTMetadataInput{
&thirdweb.NFTMetadataInput{
Name: "Cool NFT",
Description: "This is a cool NFT",
}
&thirdweb.NFTMetadataInput{
Name: "Cool NFT 2",
Description: "This is also a cool NFT",
}
}

tx, err := contract.ERC721.MintBatchTo(context.Background(), "{{wallet_address}}", metadatas)

func (*ERC721) MintTo

func (erc721 *ERC721) MintTo(ctx context.Context, address string, metadata *NFTMetadataInput) (*types.Transaction, error)

Mint an NFT to a specific wallet

@extension: ERC721Mintable

address: the wallet address to mint to

metadata: metadata of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadata := &thirdweb.NFTMetadataInput{
Name: "Cool NFT",
Description: "This is a cool NFT",
Image: image,
}

tx, err := contract.ERC721.MintTo(context.Background(), "{{wallet_address}}", metadata)

func (*ERC721) OwnerOf

func (erc721 *ERC721) OwnerOf(ctx context.Context, tokenId int) (string, error)

Get the owner of an NFT

@extension: ERC721

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

returns: the owner of the NFT

Example

tokenId := 0
owner, err := contract.ERC721.OwnerOf(context.Background(), tokenId)

func (*ERC721) SetApprovalForAll

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

Set approval for all NFTs

@extension: ERC721

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

Example

operator := "{{wallet_address}}"
approved := true

tx, err := contract.ERC721.SetApprovalForAll(context.Background(), operator, approved)

func (*ERC721) SetApprovalForToken

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

Set approval for a specific NFT

@extension: ERC721

operator: the address of the operator to approve

tokenId: the token ID of the NFT to approve

returns: the transaction receipt of the approval

Example

operator := "{{wallet_address}}"
approved := "0x..."
tokenId := 0

tx, err := contract.ERC721.SetApprovalForToken(context.Background(), operator, approved, tokenId)

func (*ERC721) TotalClaimedSupply

func (erc721 *ERC721) TotalClaimedSupply(ctx context.Context) (int, error)

Get the number of claimed NFTs

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

Example

totalClaimed, err := contract.ERC721.TotalClaimedSupply(context.Background())

func (*ERC721) TotalSupply

func (erc721 *ERC721) TotalSupply(ctx context.Context) (int, error)

Get the total number of NFTs

@extension: ERC721

returns: the supply of NFTs on this contract

Example

supply, err := contract.ERC721.TotalSupply(context.Background)

func (*ERC721) TotalUnclaimedSupply

func (erc721 *ERC721) TotalUnclaimedSupply(ctx context.Context) (int, error)

Get the number of unclaimed NFTs

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

Example

totalUnclaimed, err := contract.ERC721.TotalUnclaimedSupply(context.Background())

func (*ERC721) Transfer

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

Transfer an NFT

@extension: ERC721

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.ERC721.Transfer(context.Background(), to, tokenId)