How does a NFT smart contract store which addresses have ownership over an NFT or do they ever store this information?

My goal is to query an NFT smart contract to get (for example) a merkle tree of addresses and then generate a zk proof that a certain address is in the merkle tree.

1 Answer 1


From what I catch in your question, you would like to get the list of owners of an NFT contract. Trying to query this information manually is challenging and takes a lot of resources and time.

I suggest using a third-party API service, such as Moralis, to help you fetch the list of NFT owners to generate the zk-proof. It will be much cheaper, more efficient, and can be easily maintained in the future.

To fetch the list of NFT owners with Moralis, first install the NodeJS SDK:

npm install moralis @moralisweb3/common-evm-utils

then add this code here

import Moralis  from 'moralis';
import { EvmChain } from '@moralisweb3/evm-utils';

try {
    const chain = EvmChain.ETHEREUM;

    const address = '0x1234567890123456789012345678901234567890';

    await Moralis.start({
        apiKey: 'YOUR_API_KEY',
        // ...and any other configuration

    const response = await Moralis.EvmApi.nft.getNFTOwners({

} catch (e) {

Then, you can simply change the parameters as you need. For parameter details, check out their API reference for this API here. If you need a step-by-step tutorial for this API, they have it too right here.

For this to work, you will also need a Moralis API Key, which you can get in https://admin.moralis.io

Hope this helps!

  • 1
    thx, will definitely try this out. some alternative methods I thought of were opensea api or google big query
    Feb 28, 2023 at 18:24

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.