Skip to main content

ERC721

Functionality available for contracts that implement the ERC721 extension.

balance

Get the NFT balance of the connected wallet (number of NFTs in this contract owned by the connected wallet).

 balance = contract.erc721.balance()
Configuration

Return Value

Returns an int representing the number of NFTs owned by the connected wallet.

balance_of

Get a wallet&rsquos NFT balance (number of NFTs in this contract owned by the wallet).

 wallet_address = "{{wallet_address}}"
balance = contract.erc721.balance_of(wallet_address)
Configuration

wallet_address

The wallet address to check the balance for.

Must be a string.

 balance = contract.erc721.balance_of(
"{{wallet_address}}",
)

Return Value

Returns an int representing the number of NFTs owned by the wallet.

get

Get the metadata for an NFT in this contract using it&rsquos token ID.

Metadata is fetched from the uri property of the NFT.

If the metadata is hosted on IPFS, the metadata is fetched and made available as an object. The object&rsquos image property will be a URL that is available through the thirdweb IPFS gateway.

 token_id = 0
nft = contract.erc721.get(token_id)
Configuration

token_id

The token ID of the NFT to get the metadata for.

Must be an int.

 nft = contract.erc721.get(
"{{token_id}}",
)

Return Value

Returns an NFT object containing the NFT metadata.

class NFTMetadataOwner:
metadata: NFTMetadata
owner: str

is_approved

Get whether this wallet has approved transfers from the given operator.

This means that the operator can transfer NFTs on behalf of this wallet.

 is_approved = contract.erc721.is_approved(
# Address of the wallet to check
"{{wallet_address}}",
# Address of the operator to check
"{{wallet_address}}",
)
Configuration

owner

The wallet address that owns the NFT.

Must be a string.

 is_approved = contract.erc721.is_approved(
"{{wallet_address}}",
"{{wallet_address}}",
)

operator

The wallet address of the operator to check (i.e. the wallet that does/does not have approval).

Must be a string.

 is_approved = contract.erc721.is_approved(
"{{wallet_address}}",
"{{wallet_address}}",
)

owner_of

Get the wallet address of the owner of an NFT.

 owner = contract.erc721.owner_of("{{token_id}}")
Configuration

token_id

The token ID of the NFT to get the owner of.

Must be an int.

Return Value

Returns a string representing the wallet address of the owner of the NFT.

set_approval_for_token

Give another address approval (or remove approval) to transfer a specific one of your NFTs from this collection.

Warning

Proceed with caution. Only approve addresses you trust.

# Approve the wallet address
contract.erc721.set_approval_for_token(
"{{wallet_address}}", # The wallet address to approve
"{{token_id}}", # The token ID of the NFT to allow them to transfer
)
Configuration

operator

The wallet address to approve.

Must be a string.

token_id

The token ID of the NFT to allow the operator to transfer.

Must be an int.

set_approval_for_all

Give another address approval (or remove approval) to transfer any of your NFTs from this collection.

Warning

Proceed with caution. Only approve addresses you trust.

 contract.erc721.set_approval_for_all(
"{{wallet_address}}", # The wallet address to approve
true, # Whether to approve (true) or remove approval (false)
)
Configuration

operator

The wallet address to approve.

Must be a string.

approved

Whether to approve (true) or remove approval (false).

Must be a bool.

transfer

Transfer an NFT from the connected wallet to another wallet.

 wallet_address = "{{wallet_address}}"
token_id = 0
contract.erc721.transfer(wallet_address, token_id)
Configuration

wallet_address

The wallet address to transfer the NFT to.

Must be a string.

 contract.erc721.transfer(
"{{wallet_address}}",
"{{token_id}}",
)

token_id

The token ID of the NFT to transfer.

Must be an int.

 contract.erc721.transfer(
"{{wallet_address}}",
"{{token_id}}",
)