Unhandled Rejection (Error): call revert exception
Asked Answered
S

8

7

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
Serendipity answered 22/11, 2020 at 6:25 Comment(9)
Can you post the code that causes the error?Lebbie
Hi @Lebbie I don't know how to find it.Serendipity
Right click on the page, click Inspect and then go to the Console tab.Lebbie
Thanks! Can you post the lines that caused this error?Lebbie
I don't know how to find them. It looks like its in an "index.ts" file but, not sure where that is.Serendipity
How does your directory structure look like?Lebbie
What files do you have in src?Lebbie
@Lebbie I have provided the directory structure above.Serendipity
Do not forget to connect your Metamask account to your DAPP, the error, then, gone away for me.Schear
A
7

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

Wait the transaction ends:

await contract.deployTransaction.wait()
Alibi answered 19/5, 2021 at 2:54 Comment(0)
C
3

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.

Conjurer answered 11/3, 2022 at 6:51 Comment(0)
E
2

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.

Epiphany answered 15/11, 2021 at 18:54 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Barcellona
C
2

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.

Crinkle answered 30/11, 2021 at 1:52 Comment(0)
H
2

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

Hillhouse answered 28/4, 2022 at 1:23 Comment(0)
U
2

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
Urology answered 14/6, 2022 at 8:13 Comment(0)
S
2

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
Sherborne answered 27/6, 2022 at 17:45 Comment(0)
A
1

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);
```
Anthropomorphic answered 5/3, 2022 at 22:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.