0

I understand that the gas limit is there so that we don't lose all our ETH when something goes wrong. The gas price is there to define how much 1 gas costs. But the fee is always gas price * gas limit, so why doesn't the Ethereum blockchain simply ask for a fee cost limit?

For example, I could set:

Gas limit to 10^6 and gas price to 10^9 Wei.

Gas limit to 10^9 and gas price to 10^6 Wei.

Gas limit to 10^10 and gas price to 10^5 Wei.

It all ends up in the same transaction fee: 10^15 Wei. So when we send an ETH transaction to the blockchain, instead of

    txData = {
      nonce: 20,
      gasPrice: 1000000000,
      gasLimit: 1000000,
      to: '0x8f2b163fd3a871ce',
      value: 10^18,
      data: '0x'
    };

why wasn't it built like this:

    txData = {
      nonce: 20,
      feeLimit: 10^15,
      to: '0x8f2b163fd3a871ce',
      value: 10^18,
      data: '0x'
    };

Finally, 1 gas is paid for each line of code, so that would mean a gas limit of 1 and a gas price of 10^15 wouldn't work. In this situation wouldn't it also be handier for the blockchain to automatically calculate the fee by dividing the fee limit (10^15) by the amount of lines so users don't have to gamble on gas price and gas limit?

0

Think about depositing Ether to some exchange. It always costs you 21 000 GAS. However the GAS price is always different, sometimes you pay 1 GWei, sometimes 10 GWei. For example few days ago I paid 2 GWei and I had transaction confirmed in 5 min, today it would be 9.1 GWei - https://ethgasstation.info/

Considering this - it would be extremely hard to develop decentralized applications on Ethereum if there was no distinction between gas price and gas limit. Because gas limit does not change, when gas price changes all the time.

| improve this answer | |
  • 1
    Ooh I see. I need 21000 gas for an ETH tx, no matter if I pay 10 GWei or 100 GWei for that gas, it's still 21000 (just like I need 10 litres of gas to go from Paris to Brussels). Now you only have to adjust the gas price and not the entire fee limit, which is easier for decentralisation. – CoderApprentice Apr 16 at 15:54
1

But the fee is always gas price * gas limit

No it's not.

The fee is gas price * gas, where gas is the actual amount used during the transaction.

Nevertheless, the amount of gas in your account prior to executing the transaction must be equal to or larger than gas price * gas limit, and not just equal to or larger than gas price * gas (see more details below).

Obviously, if gas > gas limit then the transaction simply reverts.

But as you've noted yourself, gas limit is there just for "your own protection".


A more accurate description of the required amount of ether in your account prior to executing the transaction, is that it must hold at least gas limit * gas price + value wei, where:

  • gas limit is given in gas units
  • gas price is given in wei units
  • value is given in wei units (representing how much ether you pass along in the transaction)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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