Skip to main content

core.classes.erc_721

ERC721 Objects

class ERC721(Generic[TERC721], BaseContract[TERC721])

get

def get(token_id: int) -> NFTMetadataOwner

Get metadata for a token

nft = contract.get(0)
print(nft)

Arguments:

  • token_id: token ID of the token to get the metadata for

Returns:

the metadata for the token and its owner

get_all

def get_all(query_params: QueryAllParams = QueryAllParams()
) -> List[NFTMetadataOwner]

Get the metadata of all tokens in the contract

nfts = contract.get_all()
print(nfts)

Arguments:

  • query_params: optionally define a QueryAllParams instance to narrow the metadata query to specific tokens

Returns:

the metadata of all tokens in the contract

get_total_count

def get_total_count() -> int

Get the total number of NFTs minted by this contract

Returns:

the total number of NFTs minted by this contract

owner_of

def owner_of(token_id: int) -> str

Get the owner of a token

Arguments:

  • token_id: the token ID of the token to get the owner of

Returns:

the owner of the token

total_supply

def total_supply() -> int

Get the total number of tokens in the contract

Returns:

the total number of tokens in the contract

balance

def balance() -> int

Get the token balance of the connected wallet

Returns:

the token balance of the connected wallet

balance_of

def balance_of(address: str) -> int

Get the token balance of a specific address

balance = contract.balance_of("{{wallet_address}}")
print(balance)

Arguments:

  • address: the address to get the token balance of

is_transfer_restricted

def is_transfer_restricted() -> bool

Check if the contract is restricted to transfers only by admins

Returns:

True if the contract is restricted to transfers only by admins, False otherwise

is_approved

def is_approved(address: str, operator: str) -> bool

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

Arguments:

  • 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, False otherwise

transfer

def transfer(to: str, token_id: int) -> TxReceipt

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

to = "{{wallet_address}}"
token_id = 0

receipt = contract.transfer(to, token_id)

Arguments:

  • to: wallet address to transfer the tokens to
  • token_id: the specific token ID to transfer

Returns:

transaction receipt of the transfer

burn

def burn(token_id: int) -> TxReceipt

Burn a specified token from the connected wallet.

Arguments:

  • token_id: token ID of the token to burn

Returns:

transaction receipt of the burn

set_approval_for_all

def set_approval_for_all(operator: str, approved: bool) -> TxReceipt

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

Arguments:

  • operator: the address of the operator to set the approval for
  • approved: the address whos assets the operator is approved to manage

Returns:

transaction receipt of the approval

set_approval_for_token

def set_approval_for_token(operator: str, token_id: int) -> TxReceipt

Approve an operator for the NFT owner, which allows the operator to call transferFrom

or safeTransferFrom for the specified token.

Arguments:

  • operator: the address of the operator to set the approval for
  • token_id: the specific token ID to set the approval for

Returns:

transaction receipt of the approval