Error on getNFTsForContract

i have a premium account, an i using this method for retrieve the nfts of a specific contract but with some users returns this error:

Returned error: call returned result of length 142560 exceeding limit 100000
at ErrorResponse (node_modules/web3-core-helpers/lib/errors.js:28)
at <anonymous> (node_modules/web3-core-requestmanager/lib/index.js:302)
at <anonymous> (node_modules/@alch/alchemy-web3/dist/cjs/util/promises.js:28)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96)

I dont know if this is because the response exceeds the maximum size.
this is an example of the code i use:

let runners: MoralisResponse = await Moralis.Web3API.account.getNFTsForContract({
  chain: this.network,
  address: address_resolved,
  token_address: this.mintConfig.contract_wallet,
})

can you give an example of chain, address, token_addresses combination that returns that error?
it looks like a limitation from the SDK with that 100000 limit or from axios

you can try to set the limit lower and maybe the size of the result will also be lower

This is an example

let runners: MoralisResponse = await Moralis.Web3API.account.getNFTsForContract({
  chain: 'eth',
  address: '0xc08540B5ebee29a04df9eAe76F37f36D5d8973E8',
  token_address: '0xD05f71067876A68336c836aE602981728034a84c',
})

it looks like you are using moralis sdk v1, this code worked with moralis sdk v2:


Moralis = require("moralis").default

const runApp = async () => {

  await Moralis.start({
    apiKey: "API_KEY_HERE",
  });


response = await Moralis.EvmApi.nft.getWalletNFTs({
  chain: '0x1',
  address: '0xc08540B5ebee29a04df9eAe76F37f36D5d8973E8',
  tokenAddresses: ['0xD05f71067876A68336c836aE602981728034a84c'],
})

  console.log(response.toJSON());
}

runApp();

i can’t change the version of the sdk

Try to use a limit of 10 to see if it works

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.