So I'm currently working on an nft marketplace and I have this function that gets all the collections(which are proxy contracts) in the marketplace and gets basic info from the contract, like the name, symbol etc. And everything works fine when the contracts are deployed and runinng on the hardhat test network but when I deployed the contracts to the mumbai testnet I get this error;

Uncaught (in promise) Error: call revert exception (method="totalSupply()", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.5.0)
    at Logger.makeError (index.ts:225:1)
    at Logger.throwError (index.ts:237:1)
    at Interface.decodeFunctionResult (interface.ts:425:1)
    at Contract.<anonymous> (index.ts:392:1)
    at Generator.next (<anonymous>)
    at fulfilled (index.ts:2:1)

This is my code

export const getAllCollections = async () => {
  const provider = await getProvider();

  const factoryContract = new ethers.Contract(

  const nftContract = new ethers.Contract(nftaddress, NFT.abi, provider);

  const collectionsAddress = await factoryContract.getAllCollections();
  let result = [];
  for (let i = 0; i < collectionsAddress.length; i++) {
    const address = collectionsAddress[i];
    const collection = nftContract.attach(address);


    const name = await collection.name();
    const symbol = await collection.symbol();
    const thumbnail = await collection.getThumbnail();
    const userId = await collection.getUserId();

    result[i] = { name, symbol, address, thumbnail, userId };

  return result;

I tried changing the way the way i return the instance by using

 const collection = ethers.getContractAt(NFT.abi, address, provider);

But that just throws another error

Unhandled Rejection (TypeError): ethers__WEBPACK_IMPORTED_MODULE_1__.ethers.getContractAt is not a function

I and when i tried importing hardhat so that I could change the above code to

const hre = require("hardhat");

const collection = hre.ethers.getContractAt(NFT.abi, address, provider);

My application doesnt compile and throws this error:

<--- Last few GCs --->

[12580:00000272FA68BBB0]  2415158 ms: Scavenge 2037.4 (2083.5) -> 2036.6 (2093.7) MB, 16.0 / 0.0 ms  (average mu = 0.627, current mu = 0.267) allocation failure
[12580:00000272FA68BBB0]  2419309 ms: Mark-sweep (reduce) 2043.9 (2094.0) -> 2040.8 (2083.0) MB, 3300.9 / 0.2 ms  (+ 576.9 ms in 109 steps since start of marking, biggest step 41.6 ms, walltime since start of marking 3910 ms) (average mu = 0.458, current

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7CA6EE3EF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+111951
 2: 00007FF7CA67DA36 v8::internal::WebSnapshotDeserializer::context_count+65446
 3: 00007FF7CA67E8ED node::OnFatalError+301
 4: 00007FF7CAFBA78E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7CAFA540D v8::SharedArrayBuffer::Externalize+781
 6: 00007FF7CAE27F0C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
 7: 00007FF7CAE25242 v8::internal::Heap::CollectGarbage+3778
 8: 00007FF7CAE22D95 v8::internal::Heap::AllocateExternalBackingStore+1909
 9: 00007FF7CAE461B1 v8::internal::Factory::NewFillerObject+209
10: 00007FF7CAB75D35 v8::internal::DateCache::Weekday+1349
11: 00007FF7CB042B11 v8::internal::SetupIsolateDelegate::SetupHeap+472849
12: 00007FF7CB043A58 v8::internal::SetupIsolateDelegate::SetupHeap+476760
13: 00007FF7CB098722 v8::internal::SetupIsolateDelegate::SetupHeap+824098
14: 00007FF7CB036D14 v8::internal::SetupIsolateDelegate::SetupHeap+424212
15: 0000027280792239
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This my hardhat config file


const privateKey = process.env.PRIVATE_KEY;
const projectId = process.env.PROJECT_ID;

module.exports = {
  paths: {
    artifacts: "./src/artifacts",
  networks: {
    hardhat: {
      chainId: 1337,
    mumbai: {
      url: `https://polygon-mumbai.infura.io/v3/${projectId}`,
      accounts: [privateKey],
    mainnet: {
      url: `https://polygon-mainnet.infura.io/v3/${projectId}`,
      accounts: [privateKey],
  solidity: "0.8.4",

I am currently at my wits end, I have been going through the hardhat and ethers documentation, read couple of articles and tried different solutions but nothing seems to be working. Anyone knows what I'm doing wrong?

1 Answer 1


Connecting to the mainnet fixed the issue for me, seems the error is from mumbai cause the code works fine on both local and mainnet rpc. I know this isnt an optimal solution especially if you just wanna run some test but this is what worked for me and thought I should share.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.