Is there standard way how to get all types of tokens that were minted in ERC1155 contract?
Let’s say we’ve minted 30 tokens “A”, 20 tokens “B”, 10 tokens “C”.
How can I query contract to give me types A,B,C?
How can I then get totalSupply() of minted tokens per type? eg. for A totalSupply() is 30.
How opensea knows that, do they first know the metadata of all tokens per storefront/marketplace and then query contract?
@slavenR did you ever figure this out. I too am quite confused how wallets are supposed to be able to list a users various ERC1155 tokens:
For instance, I might have an ERC1155 contract that issues 100000 different types of token (each one having a different tokenId)
The ERC1155 interface does have a balanceOf(account, id)
function but this of course requires the wallet to know about the various tokenIds up front in order to use it.
The wallet could listen for all the TransferSingle events to the wallets address and derive token balances from that but surely that’s problematic too since the token may have since been transferred to some other wallet.
One could maintain a mapping in the contract that maintains the tokenIds that an address holds e.g.
mapping(address => uint256[] ) tokenIdsInWallet
and while that could work, its not a standard interface function and so wallets would not know about it