0

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!

1

1 Answer 1

1

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 Transfer events. The docs for this function are here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.