Skip to main content

core.classes.erc_1155

ERC1155 Objects

class ERC1155(Generic[TERC1155], BaseContract[TERC1155])

get

def get(token_id: int) -> EditionMetadata

Get metadata for a token

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

Arguments:

  • token_id: token ID to check the metadata for

Returns:

Metadata for the token

get_all

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

Get the metadata for all tokens on the contract

metadatas = contract.get_all()
print(metadatas)

Arguments:

  • query_params: optional QueryAllParams to define which tokens to get metadata for

Returns:

list of metadata for all tokens

get_total_count

def get_total_count() -> int

Get the total number of NFTs on the contract

Returns:

total number of tokens on the contract

get_owned

def get_owned(address: str = "") -> List[EditionMetadataOwner]

Get the metadata for all the tokens owned by an address

address = "{{wallet_address}}"
owned = contract.get_owned(address)
print(owned)

Arguments:

  • address: address to get the owned tokens for

Returns:

list of metadata for all tokens owned by the address

total_supply

def total_supply(token_id: int) -> int

Get the total number of tokens on the contract

Returns:

total number of tokens on the contract

balance

def balance(token_id: int) -> int

Get the connected wallets balance of a specific token

Arguments:

  • token_id: token ID to check the balance for

Returns:

balance of the token

balance_of

def balance_of(address: str, token_id: int) -> int

Get a specific wallets balance of a specific token

address = "{{wallet_address}}"
token_id = 0

balance = contract.balance_of(address, token_id)

Arguments:

  • address: address to check the balance for
  • token_id: token ID to check the balance for

Returns:

balance of the token

is_transfer_restricted

def is_transfer_restricted() -> bool

Check if the contract is restricted so transfers can only be made by admins

Returns:

True if the contract is restricted, False otherwise

is_approved

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

Check if an operator address is approved to manage a target addresses assets

Arguments:

  • address: address whose assets to check the approval of
  • operator: operator address to check the approval for

Returns:

True if the operator is approved, False otherwise

transfer

def transfer(to: str,
token_id: int,
amount: int,
data: Union[bytes, str] = b"0") -> TxReceipt

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

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

receipt = contract.transfer(to, token_id, amount)

Arguments:

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

Returns:

transaction receipt of the transfer

burn

def burn(token_id: int, amount: int) -> TxReceipt

Burn a specified amount of tokens from the connected wallet.

Arguments:

  • amount: amount of tokens 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 for an operator address to manage the connected wallets assets

Arguments:

  • operator: operator address to set the approval for
  • approved: True if the operator is approved, False otherwise