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!
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
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 the
Transfer events and keep track of which address holds which NFT.
With the web3.js
getPastEvents function you can get all the past
The docs for this function are here.