Got this error when getting token balances using web3

54 views Asked by At

Here I have

let web3Client = new Web3(rpcURL);
    let balanceContractInstance = new web3Client.eth.Contract(
      BalanceCheckerABI,
      balanceCheckerContract
    );

let contractAddressChunk = arrayHelper.chunk(contractAddressArr, 50);
    let balancesArr = contractAddressChunk.map((chunk) =>
      balanceContractInstance.methods.balances([address], chunk).call()
    );

This part of code balanceContractInstance.methods.balances([address], chunk).call() is throwing error below:

getTokenBalances:  ResponseError: Returned error: Unable to perform request
    at HttpProvider.<anonymous> (random_location/node_modules/web3/node_modules/web3-providers-http/lib/commonjs/index.js:61:23)
    at Generator.next (<anonymous>)
    at fulfilled (random_location/node_modules/web3/node_modules/web3-providers-http/lib/commonjs/index.js:21:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  innerError: { message: 'Unable to perform request', code: 19 },
  code: 100,
  data: undefined,
  request: undefined
}

Does anyonehave any idea to solve it?

I have tried updating web3js version , changed node versions and also tried increasing and decreasing the chunk size . Also it works fine for bsc and polygon but is giving issues for eth. It works some times but fails at other time. The address `is user wallet address.

0

There are 0 answers