调用provider.getSigner()时无法估计Gas错误;使用 etherjs 5.7 和元掩码提供程序

问题描述 投票:0回答:1
const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
const accounts = await provider.listAccounts()
console.log(await provider.getBalance(accounts[0]));
const signer = provider.getSigner();

这是代码; (这是包含在异步函数中的)

这是当调试器到达“Signer”时我收到的错误

Uncaught (in promise) Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted", method="estimateGas", transaction={"from":"0xE0462A44f97421E0A896cb2A7A31624D592ea52F","to":"0x7810ee6cbe9d0DB24d86110115A88d1200844DFd","data":"0x8632d6ed0000000000000000000000000000000000000000000000000000000000000000","accessList":null}, error={"code":-32603,"message":"execution reverted","data":{"originalError":{"code":3,"data":"0x4e487b710000000000000000000000000000000000000000000000000000000000000011","message":"execution reverted"}}}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.2)

昨晚工作得很好,但发生了一些事情,我不知道为什么。

javascript web3js metamask ethers.js
1个回答
0
投票

您的气体估计失败,因为您的调用在执行时恢复了。

错误信息是:

{
    "code": -32603,
    "message": "execution reverted",
    "data": {
        "originalError": {
            "code": 3,
            "data": "0x4e487b710000000000000000000000000000000000000000000000000000000000000011",
            "message": "execution reverted"
        }
    }
}

错误消息

0x4e487b710000000000000000000000000000000000000000000000000000000000000011
解码为
Panic(17)

您所致电的合同需要更多信息

0x7810ee6cbe9d0DB24d86110115A88d1200844DFd

© www.soinside.com 2019 - 2024. All rights reserved.