[Ethereum] How to get a list of all owners of an ERC1155 NFT by using a web3 call

erc-1155nftweb3js

With ERC721, there's the 'ownerOf' function that takes a non-fungible token's id and returns the owner address, but ERC1155 doesn't officially require that a function like that be implemented. I made an ERC1155 contract through rarible.com, and I can't find a function implemented there either. Both rarible.com and Opensea.io marketplaces show the owners of ERC1155 NFTs, so I know it's possible, but I can't figure it out.

Best Answer

UPDATE: Now you can use the Moralis API /nft/{token_address}/owners to get this directly.

This is quite difficult, as Anupam pointed out you would have to go through all the transfer events and save them to some sort of database. And this takes a lot of effort when you want to do it with a lot of big NFTs. I've never found an easy solution myself.

Full disclosure: I work at Moralis, and we've gotten a lot of these requests. And we're currently building this functionality, so hopefully in a few weeks you will be able to get this with only one line of code through the moralis SDK.

I'll edit this post once I know the full specification of this.

TheGraph is also an option, but it's a little bit cumbersome.

Related Topic