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?
1 Answer
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)
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.