Ethereum 如何计算最佳天然气限值和天然气价格?

Ethereum 如何计算最佳天然气限值和天然气价格?,ethereum,smartcontracts,cryptocurrency,Ethereum,Smartcontracts,Cryptocurrency,我正在训练写关于坚固性的文章,当我尝试在区块链中下载ERC20示例时,我需要选择气体限制和气体价格。如何计算最优? 说5 gwei的天然气价格确认时间为0.46分钟,是真的吗?我看论坛,我觉得这太少了 我需要多少汽油才能转ERC20 你可以这样计算 const gasPrice = await web3.eth.getGasPrice(); const gasPriceLimit = await web3.eth.estimateGas({ "from" : walletba

我正在训练写关于坚固性的文章,当我尝试在区块链中下载ERC20示例时,我需要选择气体限制和气体价格。如何计算最优? 说5 gwei的天然气价格确认时间为0.46分钟,是真的吗?我看论坛,我觉得这太少了


我需要多少汽油才能转ERC20

你可以这样计算

const gasPrice = await web3.eth.getGasPrice();
const gasPriceLimit = await web3.eth.estimateGas({
     "from"      : walletbase,       
     "nonce"     : value, 
     "to"        : contractAddr,     
     "data"      : data
})

我投票将这个问题作为离题题来结束,因为如果它属于任何地方,它就位于一个专门的SO for Etheriumt上web3js库有
web3.eth.estimateGas
web3.eth.getGasPrice
方法可以帮助您。