【问题标题】:Trying to call send function in web3 and it returns an error => Uncaught (in promise) Error: Returned error: unknown account尝试在 web3 中调用 send 函数并返回错误 => Uncaught (in promise) 错误:返回错误:未知帐户
【发布时间】:2022-01-07 08:53:59
【问题描述】:

我正在尝试调用智能合约的一个方法,它是一种写方法

const temp = await goin_contract.methods
    .increaseAllowance("0xEd61D93121D0b8435f9D2AaCB7dea0A3D067c4E2", stakeValue)
    .send({ from: account });

但是,每当我调用此方法时,它都会返回此错误

*Uncaught (in promise) Error: Returned error: unknown account
    at Object.ErrorResponse (errors.js:28:1)
    at index.js:302:1
    at XMLHttpRequest.request.onreadystatechange* 

智能合约的读取方法运行良好。

我已阅读有关如何解决此错误的一些文章,但找不到明确的解决方案。任何帮助将不胜感激。

【问题讨论】:

  • 您使用哪个账户发送交易?
  • 我们从 { const accounts = await window.ethereum.request({ method: "eth_requestAccounts",}); }

标签: blockchain ethereum smartcontracts web3 metamask


【解决方案1】:

您必须使用 Metamask 提供程序而不是节点 URL const web3 = new Web3(window.ethereum);

【讨论】:

    猜你喜欢
    • 2022-08-10
    • 1970-01-01
    • 2020-04-10
    • 2012-03-13
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 2018-10-02
    • 2016-03-11
    相关资源
    最近更新 更多