I have read in the documentation that the miners set the gas cost
. Does this means that gas cost varies from miner to miner? If not, how it is determined?
Moreover, when a contract is referred in geth we write:
var token = tokenContract.new(
supply,
{
from:web3.eth.accounts[0],
data:tokenCompiled.token.code,
gas: 1000000
}……….
What gas
is this? Is it the gas cost set by the client? Or the max gas to be used for the transaction?
Best Answer
In the transaction object
{ from:web3.eth.accounts[0], data:tokenCompiled.token.code, gas: 1000000 }
thegas
property is indeed the maximum to be used for the transaction.The transaction object can also have a
gasPrice
property. Miners determine whatgasPrice
they are willing to accept. If thegasPrice
is too small, the miner will ignore the transaction. Geth is configured so that it should provide a price that most miners will accept, but if you want your transaction to be potentially be processed faster by a miner, you can specify your owngasPrice
.Now gas cost equals the gas used by the transaction multiplied by
gasPrice
.