从我所读到的Ethereum白皮书来看,该系统的设计似乎是为了向您收取智能合同代码中每条指令的一些GASPRICE费用。
考虑到这一点,对于有效的代码和对现有合同的准确STARTGAS估计,似乎都会有一些额外的好处。
是否存在埃瑟姆生态系统的某些部分:
import-style语法将一些契约链接在一起。STARTGAS估计数。最重要的是,
STARTGAS数量,这样您就可以确定您所使用的合同是否准确地定价了指令集?与此相关的是,Ethereum生态系统中是否有任何部分旨在衡量和提高现有合同代码的效率?看起来,如果你有效地支付每一个计算资源使用,将有一个大的市场,以寻找更多的效率。
发布于 2018-02-15 07:05:17
是的,使用web3.eth.gasPrice() in Web3JS可以得到当前的汽油价格。
在geth控制台:
eth.gasPrice估计气体:
contract.setEmpId.estimateGas("ABC");
检查下面的示例代码,以获得估计的气体消耗量。
var contractID = "ADDRESS";
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
}
var contractABI = web3.eth.contract(<ABI>);
var contract = contractABI.at(contractID);
var estGas = contract.setEmpId.estimateGas("ABC");
var gasPrice = web3.eth.gasPrice();
var estTransPrice = eth.gasPrice*estGas;https://ethereum.stackexchange.com/questions/39713
复制相似问题