我正在 Binance Smart Chain 中开发一个 DAPP,我想知道如何计算gasLimit
令牌交易USDT
,就像它的 chrome 扩展建议交易gasLimit
并计算它的transactionFee
. 我有一个计算gasLimit
BNB 交易的公式,但这不适用于代币交易。
BNB交易计算公式:
const gasPrice = await web3.eth.getGasPrice(); // estimate the gas price
const transactionObject = {
from: SENDER_WALLET_ADDRESS,
to: RECIEVER_WALLET_ADDRESS,
gasPrice
}
const gasLimit = await web3.eth.estimateGas(transactionObject); // estimate the gas limit for this transaction
const transactionFee = gasPrice * gasLimit; // calculate the transaction fee
如果我也能像上面那样计算 transactionFee 那就太好了!!!任何帮助???