I'm new to this web3 world (but with experience of backend skills)
I would like to start a new Solidity project that gets an NFT collection as input and returns a list of all current holders.
Any help with the first steps could be great!
nftremixsolidityweb3jweb3js
I'm new to this web3 world (but with experience of backend skills)
I would like to start a new Solidity project that gets an NFT collection as input and returns a list of all current holders.
Any help with the first steps could be great!
Best Answer
As Julissa noted, in Solidity this is only achievable if the owners of the NFTs are saved in the contract.
But if you are looking to get all the holders of an NFT collection off-chain then it's fairly easy. ERC-721 tokens emit an
Transfer
event when a NFT is transferred. So you can loop over all theTransfer
events and keep track of which address holds which NFT.With the web3.js
getPastEvents
function you can get all the pastTransfer
events. The docs for this function are here.