You are viewing a single comment's thread from:

RE: Ethereum "Gas" - How it Works

in #ethereum7 years ago (edited)

Thank you for taking your time @tomshwom
Why should we create competition between transactions with gas price? Wouldnt it be better to have a fixed gas price so in the end all transactions would go through?

P.S: thinking about it more this would make transactions with low gas limit, face problems as miners will go for high cost ones preferentially.

So let me put it this way. There is a fee for any transaction to be put in a blockchain and so be accepted by the community which is what gives it its credibility (this transaction is done).
Now you can set that fee higher so your transaction goes through faster.

It is unfortunate that you have to pay the full price for a failed transaction.
You have any comments on that? Why the full gas invested should be payed?

Thanks again :)

Sort:  

Gas fees exist because there are real costs to running the blockchain. Miners spend a lot of money running their mining rigs in a Proof of Work consensus blockchain, and there are electrical/hardware costs associated with that. You have to pay miners enough to incentivize them to actually maintain the blockchain for you, and you want that incentive to be large enough that you have a truly distributed network of miners so that 1) nobody can 51% attack the network with invalid transactions, and 2) even if all of the US goes offline, the blockchain is fine.

The reason why these fees are proportional to computation (which is where the gas measurement comes from) is because it simply makes more sense. If your transaction takes more computational steps, it burns more electricity and consumes more resources from the network. You should pay for that, and the amount should be proportional to the work. These fees also deter attacks on the network with things like infinite loops. I becomes economically impossible to sustain a spam attack when miners have the choice to ignore your transaction because it's not paying enough for them.

If a transaction is included in the blockchain, it hasn't failed, and this is when you pay your gas fees. Failed transactions do not cost anything because they are never computed by the network. However, transactions that did not specify a high enough gas limit to complete the computation, had incorrect data, or were wrong in some other way do cost money because they still cost the network to process these "failed" transactions. You cannot use a global distributed network, mess up, and hope for a refund. It's just not fair to the people who did the work for you.

In the future, contracts should be written to be able to anticipate failure ahead of time and exit quickly so that the gas consumed is small. This will help save people money when they mess up their transaction, but won't hurt miners.

Clear and thorough explanation. Kudos to you!

Please correct me if im wrong. When gas limit is specified as 100 thousand and your transaction needs 1 you will pay the limit you have specified if your transaction fails. Unlike when it succeeds!? Why is that so?

The gas limit only specifies the max amount you're willing to pay. If the transaction gets mined, you only pay for the gas actually consumed. If it's mined, the transaction is technically successful (even if the results aren't what you wanted).

If it's not mined, then nobody did the computation, so nobody gets paid anything.

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.032
BTC 88143.93
ETH 3070.82
USDT 1.00
SBD 2.78