What benefits exactly we get from using gas in the network and why do we need it?
2 Answers
Ethereum is essentially a single Quasi Turing-complete computer, capable of computation just like any other computer, except for every instruction executed, there must be something expendable known as gas. Gas is essentially a limited resource required to run computation to ensure that every contract will halt/terminate and did not cause Denial of Service.
tl;dr Ethereum Developers' solution for halting problem.
- 13
- 3
-
1This couldn't be done using Ether? Why bother to introduce another factor? – Kobayashi Jun 03 '16 at 08:05
-
Gas is priced in ether. – comepradz Jun 03 '16 at 08:22
Gas is used as an ETH independent unit of accounting.
It let's you define how much a certain operation in the EVM (Ethereum Virtual Machine) should cost in relation to each other. In this sense it is a cost structure.
The benefit is to decouple the incentive structure for cheap opcodes from a certain price. If the value of ETH increases, miners can choose to lower their demand for fees in ether smoothly. So with this, a mining fee market can always adapt to ETH valuation.
- 1,255
- 1
- 9
- 14
- 11,638
- 3
- 44
- 83
-
1
-
The user that sends a transaction to a contract can pick any gas price, but the miners don't have to accepted it. It is a market. – Roland Kofler Jun 03 '16 at 08:28
-
1You mean the miners pay the price and the sender benefits from it? Or it is exactly the other way? excuse me if this is a dumb Q – Kobayashi Jun 03 '16 at 08:31
-
No the sender proposes a
gasPricehe has to pay. The miner can accept it or refuse it because it is too low. There is a default gas price of 10 Szabo currently. 1 ETH is 1 million Szabo. – Roland Kofler Jun 03 '16 at 08:37 -
1Ok, so at the end it's the miner who benefits from the
gasPriceright? – Kobayashi Jun 03 '16 at 08:39 -
Absolutely, the miner needs an incentive to run contract for the sender. The sender crafts a transaction where he sets the gasPrice and the maximal amount of Gas he is willing to spend, the
gasLimit. The miner then runs the contract until the function returns or the gasLimit is reached. All spend Gas is multiplied with the gas price and detracted from sender's account. – Roland Kofler Jun 03 '16 at 08:44 -