【发布时间】:2021-09-20 20:34:12
【问题描述】:
我正在 Binance Smart Chain 中开发一个 DAPP,我想知道如何计算 gasLimit 之类的代币交易,例如 USDT,就像它的 chrome 扩展建议交易 gasLimit 并计算它的 @ 987654324@。我有一个在 BNB 交易中计算 gasLimit 的公式,但这不适用于代币交易。
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 那就太好了! 任何帮助???
【问题讨论】:
标签: node.js smartcontracts web3 web3js binance-smart-chain