Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在批准合同后估算Gas:
WETH = weth.address; USDC = usdc.address; await usdc.approve(addr1, addr2).estimateGas;
当我尝试这个时,我有这个错误:
TypeError: usdt.approve(...).estimateGas is not a function
Truffle 使用不同的语法。您需要将函数参数传递给estimateGas(),而不是approve()函数。
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。我假设这只是创建问题时的拼写错误,与原始问题无关。
usdc
usdt