3

Now that ethereum has switched to using a base and priority fee system, what does tx.gasprice represent in solidity? Would calculating tx.gasprice - block.basefee give me the priority fee for the transaction?

2
  • Were you able to find the answer for this @jonah?
    – pbsh
    Commented Mar 4, 2022 at 17:19
  • yes. tx.gasprice - block.basefee does equal the priority fee per gas. At least that's what I concluded from sending test transactions to my solidity contract.
    – Jonah
    Commented Mar 5, 2022 at 19:17

1 Answer 1

4

As specified by the EIP:

The GASPRICE (0x3a) opcode MUST return the effective_gas_price

priority_fee_per_gas = min(transaction.max_priority_fee_per_gas, transaction.max_fee_per_gas - block.base_fee_per_gas)
effective_gas_price = priority_fee_per_gas + block.base_fee_per_gas

So tx.gasprice returns the actual gas price of the transaction (even post -1559)

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.