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?

1

1 Answer 1

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.

3
  • 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. Jul 6, 2016 at 7:05
  • ethereum.stackexchange.com/questions/3943/… and also look at geth help miner options.
    – eth
    Jul 6, 2016 at 7: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 7, 2018 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.