I would like to be able to call all the addresses for a specific tokenId in an ERC1155 contract in order to airdrop those with a specific token. I know ERC721 has the function ownerof to allow for this, is there an equivalent for ERC1155?
1 Answer
There is no function for this on ERC1155
.
Because a token is not necessarily unique, it can have multiple owners.
Same as ERC20
there is no function to list all the holders.
On ERC1155 _balances
mapping is like this:
mapping(uint256 => mapping(address => uint256)) private _balances;
Simple representation:
TokenID => holder => amountOfTokenID
For one TokenID
you can have multiple holders
To answer your question: It is not possible to retrieve this information from the smart contract.
However, it is possible to get this information off-chain using events
with the right logic / filters
Or via TheGraph.
-
The mapping you mentioned is available in the ERC1155 standard? Commented Apr 13, 2023 at 11:18
-