尽管使用send设置函数可以工作,但为什么使用call从Web3调用方法却给出了错误

问题描述

我刚接触solidity,只是在测试教程中的一些示例。 **问题是尽管我可以调用set函数,但我无法调用get函数。**我将Remix IDE用于智能合约,将Geth用于客户端,将React.js用于UI。我该如何解决这些错误。每当我调用get函数显示输出时,都会出现以下错误

错误:返回的值无效,是否用完了?如果您没有为要从中检索数据的合同使用正确的ABI,从不存在的块号中请求数据或查询未完全同步的节点,也可能会看到此错误。位于ABICoder.push ../ node_modules / web3-eth-abi / lib / index.js.ABICoder.decodeParameters(index.js:286)位于Contract.push ../ node_modules / web3-eth-contract / lib / index。在Method.push ../ node_modules / web3-core-method / lib / index.js.Method.formatOutput(index.js)的Method.outputFormatter(index.js:760)上的js.Contract._decodeMethodReturn(index.js:470) js:147)位于sendTxCallback(index.js:523)位于XMLHttpRequest.request.onreadystatechange(index.js:98)的index.js:293

这是我的set函数,并用App.js编写函数

    e.preventDefault();
    const accounts = await web3.eth.getAccounts();
    const account = accounts[0];
    const gas = await RemixContract.methods
      .setMessage(this.state.message)
      .estimateGas();
    await RemixContract.methods
      .setMessage(this.state.message)
      .send({ from: account,gas })
      .then((res) => console.log(res))
      .catch((e) => console.log(e));
  }

  async getDefaultData() {
    await RemixContract.methods
      .defaultMessage()
      .call()
      .then((res) => console.log("response " + res))
      .catch((e) => console.log(e));
  }```

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...