0
  1. When I deploy a contract by sending a new transaction, the miner who adds the transaction to the blockchain gets the gas, right?
  2. When I execute I contract by sending a new transaction, the miner who adds the transaction to the blockchain gets the gas. But just for adding the transaction and not for execution?

So my main question: When all nodes have to execute the smart contract who (which node) gets the gas for the computation?

1 Answer 1

0

Gas is the accounting system used to work out how much ether the sender pays to perform transaction.

The ethereum yellow paper (appendix G) sets out the schedule of gas prices per EVM operation.

The transaction sender sets a value in ether that they are willing to pay per unit of gas.

The miners can survey the pool of valid transactions and pick the ones willing to pay the most ether such that the total gas is not over the block gas limit (presently 12500000).

They are free to pick any valid transaction (or even no transactions) within this.

As you might expect they tend to pick the ones with the highest gas price offer. See this visualization of the tx pool: https://txpool.zengo.com/#0,24h

They add any address they like to receive they block reward (before they start hashing). Presumably again they tend to pick an address they control.

In general, they amount of "computational work" done to perform the transaction computations is small compared to the work done in mining.

To your questions:

  1. The miner chooses which account gets the specified ether per unit gas used by the transaction.
  2. The miner chooses which account gets the block reward for adding a block, and any gas fees for adding transactions.
4
  • Thanks atomh33ls for your answer, but now I'm even more confused. For the mining process the miner gets already some ether. Which account gets the gas (ether)? When all nodes have to execute the smart contract then it would be logical when all get some part of it. Aug 5, 2020 at 18:12
  • @user1117605 On the ETH1 system the miners race to get the reward and the gas (ether derived from gas use paid by sender). Imagine a network with two miners, each with a hash rate of 1 hash per sec, each has a 50% chance of finding the first valid hash for a given block. so over a large number of blocks it pans out to ~50-50. Obv the real hash rate is much higher and many more computers mining, but principle applies.
    – Lee
    Aug 5, 2020 at 19:44
  • Thanks again atomh33ls, but this does not answer my question who gets the gas for the smart contract execution. Aug 6, 2020 at 20:34
  • @user1117605 The miner gets the ether paid for gas. Jan 5, 2021 at 2:57

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.