0

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

4
  • 2
    I’m voting to close this question because the authur is just asking for someone to write code for them
    – natewelch_
    Commented 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
    Commented Aug 26, 2021 at 20:56
  • "Ideally I'm looking for JS/typescript code"
    – natewelch_
    Commented 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
    Commented Nov 23, 2021 at 14:37

1 Answer 1

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 you have read our privacy policy.

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