Covalent plugin getBlockTokenHolders usage from cloud function throws error for address parameter

Im trying to make use of the covalent plugin

  let o = {
    chainId: 1,
    address: request.params.address
  };
  logger.info("OPTIONS " + JSON.stringify(o))
  let b = await Moralis.Plugins.covalent.getBlockTokenHolders({address: o.address, chainId: o.chainId});

  logger.info(JSON.stringify(b));

  logger.info("past covalent request");

I dont get a result printed, log shows this

2022-03-25T09:47:47.061Z - past covalent request
2022-03-25T09:47:47.057Z - {"status":502,"data":{"error":true,"data":[{"code":400003,"message":"The parameter `address` is not present"}]}}
2022-03-25T09:47:47.023Z - OPTIONS {"chainId":1,"address":"0x6262998ced04146fa42253a5c0af90ca02dfd2a3"}

Is it working when you try to run it locally?

It is throwing me an error when I try to run it on the browser console.

Uncaught Error: [object Object]
    at handleError (moralis.js:26394:17)

What error do you get if you remove the chainId property from the API call?

I am also getting the same error 502 with or without chainId.

It works fine if you use it in front end?

no. I am receiving the same error in fontend.

from documentation (https://moralis.io/plugins/covalent/)
it looks like the parameters are different:

interface GetBlockTokenHoldersDto {
  chainId: number;
  contractAddress: Address;
  blockHeight: string;
  pageNumber?: number;
  pageSize?: number;
  quoteCurrency?: string;
}

mainly contractAddress vs address

Now I understand where I lost.
The documentation shows the wrong function name for GetTokenBalancesForAddress.
It should say this.
await Moralis.Plugins.covalent.getTokenBalancesForAddress(GetTokenBalancesForAddressDto);

interface GetTokenBalancesForAddressDto {
  chainId: number;
  address: Address;
  quoteCurrency?: string;
}

2 Likes

@glad

@johnversus thanks for the info, reported in on community channel

thanks, the documentation is updated now