【问题标题】:Estimate gas in ETH from an approve contract从批准合同中估算 ETH 中的 gas
【发布时间】:2022-01-14 19:56:40
【问题描述】:

我想在批准合同后估算Gas:

WETH = weth.address;
USDC = usdc.address;

await usdc.approve(addr1, addr2).estimateGas;

当我尝试这个时,我遇到了这个错误:

TypeError: usdt.approve(...).estimateGas is not a function

【问题讨论】:

    标签: ethereum truffle hardhat


    【解决方案1】:

    Truffle 使用不同的语法。您需要将函数参数传递给estimateGas(),而不是approve() 函数。

    await usdc.approve.estimateGas(addr1, addr2);
    

    文档:http://trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts#special-methods-on-truffle-contract-objects

    注意:您的代码定义了usdc,然后错误消息指出usdt。我假设这只是创建问题时的拼写错误,与原始问题无关。

    【讨论】:

      猜你喜欢
      • 2021-08-14
      • 2022-07-06
      • 2022-06-14
      • 2022-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      相关资源
      最近更新 更多