Web3js 17: 查询平均 gas 价格

300 阅读1分钟

前言

求其区块链团队出品

旗下网站


查询平均 gas 价格

查询当前网络平均 gas 价格

web3.eth.getGasPrice()
.then(function(gasPrice) {
    console.log("当前平均 gas 价格为:" + web3.utils.fromWei(gasPrice, 'ether') + " ether");
})
.catch(function(error) {
    console.log("出错了:" + error);
});