0

When rlp encoding an EIP1559 transaction 3 gas values are provided: maxPriorityFeePerGas,maxFeePerGas & gasLimit.

maxFeePerGas = BaseFee + maxPriorityFeePerGas but what is the purpose of gasLimit and how does it interact with the other 2 gas properties?

1 Answer 1

3

The purpose of gas limit is to specify the maximum amount of gas you are willing to consume in a transaction. EIP-1559 introduces a maxFeePerGas and maxPriorityFeePerGas. These values determine how much you are willing to pay per gas used by the transaction. Similarly to how the gas price works, if your transaction has a maxPriorityFeePerGas of 10 Gwei and your transaction uses 21,000 gas (gasLimit), you will end up paying (at most) 21,000 × 10 Gwei = 0.00021 Ether.

How much you actually pay depends on the BaseFee, however. With a max fee of 10 Gwei and a BaseFee of 5 Gwei, you will end up paying only 5 Gwei per gas (ignoring the priority fee for now). The maxFeePerGas specifies how much you are willing to pay at most. If this number is lower than the current BaseFee, your transaction won't be confirmed (until the BaseFee drops or the transaction is removed from the transaction pool).

1
  • thanks @Yongjian that makes sense so every opcode in a contract ex. PUSH1 gas: 3 is multiplied by (baseFee + maxPriority) or maxFee . So when interacting with a contract, the contract needs to be completely simulated first to figure out the gas units consumed to populate gasLimit? Commented Nov 14, 2022 at 16:16

Your Answer

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

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