5

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?

Ahmed Ashour
  • 103
  • 3
Sukhmaninder
  • 491
  • 2
  • 6
  • 14

1 Answers1

5

In the transaction object { from:web3.eth.accounts[0], data:tokenCompiled.token.code, gas: 1000000 } the gas property is indeed the maximum to be used for the transaction.

The transaction object can also have a gasPrice property. Miners determine what gasPrice they are willing to accept. If the gasPrice 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 own gasPrice.

Now gas cost equals the gas used by the transaction multiplied by gasPrice.

eth
  • 85,679
  • 53
  • 285
  • 406
  • How gas price is determined? Each miner can specify his own cost, how geth determines the market gas price? And what if user is willing to pay higher gas price than the miner is expecting: is the client charged his price or the miner's? And yes the link you have given partially solved my problem, thanks. – Sukhmaninder Jul 06 '16 at 07:05
  • http://ethereum.stackexchange.com/questions/3943/how-does-gas-price-oracle-work and also look at geth help miner options. – eth Jul 06 '16 at 07:39
  • gasPrice is what YOU are willing to pay. The miners choose which transactions to mine based on gas price (obviously, the higher the gas price, the faster the transaction is mined) – gaiazov Jan 07 '18 at 03:36