web3.eth.gasPrice,返回当前的gas价格。这个值由最近几个块的gas价格的中值决定。只读属性。
同步调用:
web3.eth.gasPrice
异步调用:
web3.eth.getGasPrice(callback(error, result){ ... })
返回值:
- BigNumber - 当前的gas价格的BigNumber实例,以wei为单位。
示例:
var gasPrice = web3.eth.gasPrice;
console.log(gasPrice.toString(10)); // "10000000000000"
如果你希望高效的学习以太坊DApp开发,可以访问汇智网提供的最热门在线互动教程:
其他更多内容也可以访问这个以太坊博客。