Unhandled Rejection (Error): call revert exception

18.2k views Asked by At

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
8

There are 8 answers

0
JimClayton On

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

0
Silvio Guedes On

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

Wait the transaction ends:

await contract.deployTransaction.wait()
0
Calypso On

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);
```
0
Jasperan On

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.

0
Tanmay Banerjee. On

First make sure your local blockchain network npx hardhat node is running in a separate terminal and access the local network console in a separate terminal npx hardhat console --network localhost.

If the error still pops up for the commands fired in the terminal of local network console, then The way to resolve the issue is to check the logs presented in the terminal where your local blockchain network is running.

For my case I created the contract instance with wrong address. And every time I did try to execute the functions of the contract instance created with wrong address, for each execution there was a log in the terminal running the local blockchain network as :

WARNING: Calling an account which is not a contract
From:                0xf39fd6e51aad88f......................266
To:                  0xf39fd6e51aad88f......................266
0
ArtDev On

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.

0
Infomal Haut On

Try to deploy the main contract again.

Run the below commands in separate terminals parallelly

npx hardhat node

npx hardhat run scripts/deploy.js --network localhost
1
alok thakur On

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.