'Unhandled Rejection (Error): call revert exception

I am getting this error message when trying to interact with my smart contract on my react front end. I am running localhost3000 and which requires metamask to sign in.

Unhandled Rejection (Error): call revert exception (method="symbol()", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.8)
Logger.makeError
/Users/username/Desktop/final-4/src.ts/index.ts:205
Logger.throwError
/Users/username/Desktop/final-4/src.ts/index.ts:217
Interface.decodeFunctionResult
/Users/username/Desktop/final-4/src.ts/interface.ts:326
  323 |     eventFragment = this.getEvent(eventFragment);
  324 | }
  325 | const topics = [];
> 326 | const dataTypes = [];
      | ^  327 | const dataValues = [];
  328 | if (!eventFragment.anonymous) {
  329 |     topics.push(this.getEventTopic(eventFragment));

View compiled
Contract.<anonymous>
/Users/username/Desktop/final-4/src.ts/index.ts:309
fulfilled
http://localhost:3000/static/js/0.chunk.js:5079:24

Also from the source tab in inspect:

Uncaught (in promise) Error: call revert exception (method="symbol()", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.8) Uncaught (in promise) Error: call revert exception (method="balanceOf(address)", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.8)

Here is my directory structure:

client
|--node_modules
|-—public
   |—-src
   |—-contracts
      |—-Address.json
      |—-Context.json
      |—-ERC20.json
      |—-IERC20.json
      |—-Migrations.json
      |—-PreciousChicken.json
      |——SafeMath.json
   |—-App.css
   |—-App.js
   |—-App.test.js
   |—-index.css
   |—-logo.svg
   |—-reportWebVitalls.js
   |—-setupTests.js
   |—-gitignore
   |—-package-lock.json
   |—-package.json
   |—-yarn.lock
|—-contracts
   |—-Migrations.sol
   |—-MyPreciousToken
   |—-migrations
      |—-1_initial_migations.js
      |—-2_deploy_contracts.js
|—-node-modules
|—-test


Solution 1:[1]

This error (CALL_EXCEPTION) happens when your smart contract is not deployed yet.

Wait the transaction ends:

await contract.deployTransaction.wait()

Solution 2:[2]

I got the same error because I was trying to use a contract's Ropsten address instead of it's Mainnet address. Make sure that whatever contract you're using is deployed and is on the correct network.

Solution 3:[3]

Connecting a proper test network in the wallet could prevent this issue while you are building a smart contract in the test network. E.g for me, I had to connect Rinkeby network in the wallet, but actually pointing a main network.

Solution 4:[4]

I got this error when trying to access an element of a public array that didn't exist. The array had only one element inside so I had to change from index 1 to 0.

const elIndex = ethers.BigNumber.from(0);
await ExampleContract.nfts(elIndex);
```

Solution 5:[5]

For me the reason was when I redeployed the contract, the contract's json files generated in the build needed to be replaced in my react app as well.

Solution 6:[6]

Double check that your contract is deoloyed on what ever test network you are using ! I ran npx hardhat run scripts/deploy.js --network localhost while my testnet was running in a seperate terminal and, it fixed the error.

hope this helps anyone

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Silvio Guedes
Solution 2
Solution 3 ArtDev
Solution 4 Calypso
Solution 5 Jasper
Solution 6 JimClayton