从批准的合约中估算 ETH 中的气体
Estimate gas in ETH from an approve contract
我想在批准合同后估算 Gas :
WETH = weth.address;
USDC = usdc.address;
await usdc.approve(addr1, addr2).estimateGas;
当我尝试此操作时出现此错误:
TypeError: usdt.approve(...).estimateGas is not a function
Truffle 使用不同的语法。您需要将函数参数传递给 estimateGas()
,而不是 approve()
函数。
await usdc.approve.estimateGas(addr1, addr2);
注意:您的代码定义了 usdc
,然后错误消息指出 usdt
。我假设这只是创建问题时的错字,与原始问题无关。
我想在批准合同后估算 Gas :
WETH = weth.address;
USDC = usdc.address;
await usdc.approve(addr1, addr2).estimateGas;
当我尝试此操作时出现此错误:
TypeError: usdt.approve(...).estimateGas is not a function
Truffle 使用不同的语法。您需要将函数参数传递给 estimateGas()
,而不是 approve()
函数。
await usdc.approve.estimateGas(addr1, addr2);
注意:您的代码定义了 usdc
,然后错误消息指出 usdt
。我假设这只是创建问题时的错字,与原始问题无关。