【问题标题】:ERROR Error: Uncaught (in promise): Error: call revert exceptionERROR 错误:未捕获(在承诺中):错误:调用恢复异常
【发布时间】:2022-07-19 04:27:21
【问题描述】:

使用 angular 和moralis 时,每当我尝试读取任何视图函数时都会出现此错误。下面是返回错误的函数

async contractBalance() {
    let options = {
      contractAddress: CONTRACT_ADDRESS,
      functionName: "investorCount",
      abi: ABI
    }
await Moralis.enableWeb3();
return await Moralis.executeFunction(options);}

下面是我的 abi 和函数的链接

https://www.dropbox.com/s/cpbne99coinerm2/abi.ts?dl=0

https://www.dropbox.com/scl/fi/sp26mrdpllghc6de63w9k/Document.docx?dl=0&rlkey=9fjrpc9s91wldbuq8mahdfuae

Github 回购 https://github.com/orajiakuchibuchi/ETH-INVEST

这是我的仓库的链接,登录后,使用 rinkeby 网络进行元掩码,在身份验证后从指南页面导航到仪表板。仪表板页面中抛出错误,blockchainService line 206

【问题讨论】:

  • 你能发布错误吗?
  • @NiccolòFant Github Repo github.com/orajiakuchibuchi/ETH-INVEST 这是我的 repo 的链接,登录后,使用 rinkeby 网络进行元掩码,在身份验证后从指南页面导航到仪表板。仪表盘页面中抛出错误,blockchainService line 206

标签: angular solidity web3js angular12 moralis


【解决方案1】:

您确定investorCount 的格式正确吗?

它应该看起来像这样。

const ABI = [
 {
    inputs: [],
    name: "message",
    outputs: [
      {
        internalType: "string",
        name: "",
        type: "string",
      },
    ],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [
      {
        internalType: "string",
        name: "_newMessage",
        type: "string",
      },
    ],
    name: "setMessage",
    outputs: [],
    stateMutability: "nonpayable",
    type: "function",
  }
];

const readOptions = {
  contractAddress: "0xe...56",
  functionName: "message",
  abi: ABI
};

const message = await Moralis.executeFunction(readOptions);
console.log(message)
// -> "Hello World"

【讨论】:

【解决方案2】:

如果您只需要读取数据,则不必启用 Web3。 试试这样的:

const ABI = [...]

const options = {
   address: "xxxx",
   function_name: "investorCount",
   abi: ABI
};

const res = await Moralis.Web3API.native.runContractFunction(options);

如果你想看看 Moralis docs

【讨论】:

  • ERROR 错误:未捕获(在承诺中):错误:返回值无效,它是否耗尽了 Gas?如果您没有为从中检索数据的合约使用正确的 ABI、从不存在的块号请求数据或查询未完全同步的节点,您也可能会看到此错误。错误:返回的值无效,是否耗尽了 Gas?如果您没有为从中检索数据的合约使用正确的 ABI、从不存在的块号请求数据或查询未完全同步的节点,您也可能会看到此错误。
  • github.com/orajiakuchibuchi/ETH-INVEST 这是我的仓库的链接,登录后,使用 rinkeby 网络作为元掩码,在身份验证后从指南页面导航到仪表板。仪表盘页面中抛出错误,blockchainService line 206
猜你喜欢
  • 2022-11-11
  • 2022-12-19
  • 2018-06-06
  • 1970-01-01
  • 2021-03-03
  • 2021-02-01
  • 1970-01-01
  • 2021-11-28
  • 1970-01-01
相关资源
最近更新 更多