首页 > 解决方案 > 未处理的拒绝(错误):调用恢复异常

问题描述

尝试在我的反应前端与我的智能合约交互时收到此错误消息。我正在运行 localhost3000 并且需要元掩码才能登录。

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

同样来自检查中的源选项卡:

未捕获(承诺中)错误:调用恢复异常(method="symbol()",errorSignature=null,errorArgs=[null],reason=null,code=CALL_EXCEPTION,版本=abi/5.0.8)未捕获(承诺中)错误:调用恢复异常(method="balanceOf(address)", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.8)

这是我的目录结构:

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

标签: reactjsfrontendethereumsolidityerc20

解决方案


当您的智能合约尚未部署时,会发生此错误(CALL_EXCEPTION)。

等待交易结束:

await contract.deployTransaction.wait()

推荐阅读