getAllTokenIds not adhering to documentation?

We have to integrate with an ERC1155 which has token ids with a large amount of tokens. We want to dynamically receive the current supply for a specific token id.

calling the following function returns a huge array because each owner is a separate entry in the array
https://docs.moralis.io/moralis-server/web3-sdk/account#getnftsforcontract

Trying to use getAllTokenIds seemed like it should return what we want but it also includes the “owner_of” field, resulting in the huge array where we can’t get any data unfortunately.
https://docs.moralis.io/moralis-server/web3-sdk/token#getalltokenids

1 Like

I don’t know yet the answer to your question regarding what Moralis.Web3API.token.getAllTokenIds should return, this is somehow related to this: Moralis not indexing some NFTs in a contract on polygon

Any update? Still facing the issue

I don’t have an update yet, maybe I have it today/tomorrow.

do you have an update for me?

it looks like we’ll have to fix it, it doesn’t look like it works as expected now

I think there is some misunderstanding here

@cryptokid thought it’s something with metadata

@dagr you mean it’s the response structure of how owners are represented? Can you clarify what is not adhering to docs exactly?

trying to understand what you mean with resulting in the huge array where we can’t get any data unfortunately. Please give the array example that doesnt work for you

1 Like

i now understand the issue more, hopefully we can get a fix next week

exactly, so as mentioned above we want to get all information about an NFT contract. Especially with an ERC1155 we run into the issue here. To name a specific example, the Swiss Crypto Stamp (on polygon, address 0x6ddcc90614d47acd7596447686c4fd6aee782742) has 175k NFTs over 13 token Ids distributed to 175k paper wallets (real world stamps). Calling this function I would expect the following outcome according to the documentation:

[
  {
    "token_address": "0x6ddcc90614d47acd7596447686c4fd6aee782742",
    "token_id": "1",
    "amount": "65000",
    "contract_type": "ERC1155",
    "token_uri": "tokenuri for token id 1",
    "metadata": "metadata for token id 1",
    ...
  },
  {
    "token_address": "0x6ddcc90614d47acd7596447686c4fd6aee782742",
    "token_id": "2",
    "amount": "45000",
    "contract_type": "ERC1155",
    "token_uri": "tokenuri for token id 2",
    "metadata": "metadata for token id 2",
    ...
  },
  ...,
  {
    "token_address": "0x6ddcc90614d47acd7596447686c4fd6aee782742",
    "token_id": "13",
    "amount": "50",
    "contract_type": "ERC1155",
    "token_uri": "tokenuri for token id 13",
    "metadata": "metadata for token id 13",
    ...
  }
]

But the actual outcome is:

[
  {
    "token_address": "0x6ddcc90614d47acd7596447686c4fd6aee782742",
    "token_id": "1",
    "amount": "1",
    "owner_of": "0x......1",
    "contract_type": "ERC1155",
    "token_uri": "tokenuri for token id 1",
    "metadata": "metadata for token id 1",
    ...
  },
  {
    "token_address": "0x6ddcc90614d47acd7596447686c4fd6aee782742",
    "token_id": "1",
    "amount": "1",
    "owner_of": "0x......2",
    "contract_type": "ERC1155",
    "token_uri": "tokenuri for token id 1",
    "metadata": "metadata for token id 1",
    ...
  },
  {
    "token_address": "0x6ddcc90614d47acd7596447686c4fd6aee782742",
    "token_id": "1",
    "amount": "2",
    "owner_of": "0x......3",
    "contract_type": "ERC1155",
    "token_uri": "tokenuri for token id 1",
    "metadata": "metadata for token id 1",
    ...
  },
  ...
]

So essentially for every owner of an NFT there is a separate entry with the amount of tokens that specific owner is holding. Meaning that the result we receive back has ~175,000 entries, one for every paper wallet / stamp (meanwhile some NFTs have been transferred to wallets, so it’s only approximately 175k individual owners now).
So right now getNFTsForContract and getAllTokenIds return the same, that’s why I was suspecting a wrong return value in the first place, because it’s currently redundant.
If there is any more questions I’m happy to help.

we have an update now for getAllTokenIds where it is only one entry per token id

Thank you! will try it out today. Is it also possible to call this function within a Cloud Function somehow?

you can call it from a cloud function without problems


One of our devs just tested the function, although the owner_of field is gone now, there is still multiple entries per token id

1 Like

same here Moralis not indexing some NFTs in a contract on polygon

1 Like

should be fixed now.