Skip to main content

ERC1155

Functionality available for contracts that implement the ERC1155 extension.

balance

Get the quantity of a specific NFT owned by the connected wallet.

token_id = 0 # Id of the NFT to check
balance = contract.erc1155.balance(token_id)
Configuration

token_id

The token ID of the NFT to check the balance of.

Must be an int.

balance = contract.erc1155.balance(
token_id,
)

Return Value

An int representing the quantity of the NFT owned by the wallet.

balance_of

Get the quantity of a specific NFT owned by a wallet.

# Address of the wallet to check NFT balance
wallet_address = "{{wallet_address}}"
token_id = 0 # Id of the NFT to check
balance = contract.erc1155.balance_of(wallet_address, token_id)
Configuration

address

The wallet address to check the NFT balance for.

Must be a string.

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

token_id

The token ID of the NFT to check the balance of. Must be an int.

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

Return Value

An int representing the quantity of the NFT owned by the wallet.

get

Get the metadata of an NFT 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 a EditionMetadata object. The object&rsquos image property will be a URL that is available through the thirdweb IPFS gateway.

nft = contract.erc1155.get(0)
Configuration

token_id

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

Must be an int.

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

Return Value

Returns an EditionMetadata object containing the following properties:

class EditionMetadata:
metadata: NFTMetadata
supply: int

class NFTMetadata:
id: int
uri: str
name: str
description: Optional[str] = None
image: Optional[str] = None
external_url: Optional[str] = None
animation_url: Optional[str] = None
background_color: Optional[str] = None
properties: Optional[Dict[Any, Any]] = None
attributes: Optional[Dict[str, Any]] = None

transfer

Transfer an NFT from the connected wallet to another wallet.

to = "0x7fDae677aA6f94Edff9872C4b91D26407709c790"
token_id = 0
amount = 1

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

to

The wallet address to send the NFT to.

Must be a string.

contract.erc1155.transfer(
"{{wallet_address}}",
"{{token_id}}",
"{{amount}}",
)

token_id

The token ID of the NFT to transfer.

Must be an int.

contract.erc1155.transfer(
"{{wallet_address}}",
"{{token_id}}",
"{{amount}}",
)

amount

The quantity of the NFT to transfer.

Must be an int.

contract.erc1155.transfer(
"{{wallet_address}}",
"{{token_id}}",
"{{amount}}",
)

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.erc1155.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.erc1155.is_approved(
"{{wallet_address}}",
"{{wallet_address}}",
)

operator

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

Must be a string.

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

Return Value

A bool representing whether the wallet address has approval.

set_approval_for_all

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

Warning

Proceed with caution. Only approve addresses you trust.

 x_result = contract.erc1155.set_approval_for_all(
# Address of the wallet to approve
"{{wallet_address}}",
# Whether to grant approval (true) or remove approval (false)
true,
)
Configuration

operator

The wallet address to approve.

Must be a string.

tx_result = contract.erc1155.set_approval_for_all(
"{{wallet_address}}",
true,
)

approved

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

Must be a bool.

 txResult = contract.erc1155.setApprovalForAll(
"{{wallet_address}}",
true,
)

total_count

Get the total number of unique NFTs in the collection.

total_count = contract.erc1155.total_count()

Return Value

Returns an int representing the total number of unique NFTs in the collection.

total_supply

Returns the total supply of a token in the collection, including burned tokens.

total_supply = contract.erc1155.total_supply("{{token_id}}")
Configuration

token_id

The token ID of the NFT to get the total supply of.

total_supply = contract.erc1155.total_supply(
"{{token_id}}",
)

Return Value

Returns an int representing the total supply of the token.