For preparing an Airdop, for example, I want to find all owners of a specific NFT contract at a set date (today is OK, just actual hodlers, not all previous owners).

In doing some digging most APIs seem to provide event listeners, so I would need to have a server out there constantly available and listening.

I can also see you could set up a subgraph on thegraph or other indexer and it would do the listening for you?

What are some other ways to do queries on the chain and filter for owners of a contract? It seems heavy duty to query/filter the whole blockchain.

Ideally I'm looking for JS/typescript code.

related questions and research below, really looking for advice on the best option here :D

  • 2
    I’m voting to close this question because the authur is just asking for someone to write code for them
    – natewelch_
    Aug 26, 2021 at 18:40
  • not really, i'm looking for advice on the best way to do it - with an indexer, or even adding a function to the contract to make it enumerable. I'm not sure of the trade offs from doing that - gas cost of keeping the data on-chain so its always available. its a common question, but actually quite deep in it's implications. There maybe a fn in ethers that handles this, but ERC721 doesn't afaik.
    – dcsan
    Aug 26, 2021 at 20:56
  • "Ideally I'm looking for JS/typescript code"
    – natewelch_
    Sep 7, 2021 at 14:55
  • @dcsan This answer ethereum.stackexchange.com/a/64814 is exactly what you are looking for. You even commented on it, why didn't it work for you?
    – Ismael
    Nov 23, 2021 at 14:37

1 Answer 1


You can query the NFT id and iterate through it, 0 - n, calling owners.push(await tokenContract.ownerOf(i))

Your Answer

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

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