View on GitHub

web3js-cn

web3.eth.estimateGas

估计调用需要耗费的gas量。这个方法在节点的VM中执行一个消息调用或交易,但是不会修改区块链。

调用:

web3.eth.estimateGas(callObject [, callback])

参数:

返回值:

示例:

var result = web3.eth.estimateGas({
    to: "0xc4abd0339eb8d57087278718986382264244252f", 
    data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"
});
console.log(result); 
//输出 "0x0000000000000000000000000000000000000000000000000000000000000015"

教程推荐: