16

I have an application that sends legacy transactions containing to, from, gasPrice, gasLimit, value and data properties.

I know that following the London Fork there is backward compatibility with legacy transactions, however, in order to prepare and to make use of the updates in EIP 1559 I want to test the new transaction types in Ropsten Testnet. My understanding is that the London Fork is already applied in Ropsten Testnet.

Can someone point me to an example transaction that uses the new fields in EIP 1559 and what to expect in the transaction receipt? I want to know the correct transaction payload to send and the expected receipt to receive.

Below is an example of how I think a transaction payload might look (some fields omitted for brevity):

{
   from: 0x111...
   to: 0x222...
   type: 0x2 <-- do I need to set this now?
   maxPriorityFeePerGas: 10000000000 <-- pay 10 GWei for priority gas fees
   maxFeePerGas .... <-- do I need to set this?
}

1 Answer 1

17
+200

EIP-1559 transactions are typed transactions (see EIP-2718), where the type for EIP-1559 transactions is specified as 0x02. The payload of the EIP-1559 transactions consists of (as JSON):

{
  "gas": "0x5208", // = gasLimit
  "maxFeePerGas": "0xb2d05e00",
  "maxPriorityFeePerGas": "0xb2d05e00",
  "input": "0x",   // = data
  "nonce": "0xa",
  "to": "0xc6d5a3c98ec9073b54fa0969957bd582e8d874bf",
  "value": "0x0",
  "accessList": [],
  "chainId": "0x5"
}

Here is an example of the above EIP-1559 transaction on Etherscan (on Goerli): https://goerli.etherscan.io//tx/0xeb403182d4e2f2705d012e864ac5316c54ceddfc0ee583c730c918040520a75a

The raw transaction receipt of this transaction looks like this:

{
  "blockHash": "0xee4df7e9d55b56162346fb779c074fe897bc6bb737051ab776a83a2b6f15962d",
  "blockNumber": "0x4fef3c",
  "contractAddress": null,
  "cumulativeGasUsed": "0xa410",
  "effectiveGasPrice": "0xb2d05e00",
  "from": "0xc6d5a3c98ec9073b54fa0969957bd582e8d874bf",
  "gasUsed": "0x5208",
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": "0x1",
  "to": "0xc6d5a3c98ec9073b54fa0969957bd582e8d874bf",
  "transactionHash": "0xeb403182d4e2f2705d012e864ac5316c54ceddfc0ee583c730c918040520a75a",
  "transactionIndex": "0x1",
  "type": "0x2"
}

Note that the type is not used as transaction payload itself, but rather specified as the EIP-2718 transaction type (where a transaction consists of TransactionType || TransactionPayload).

The maxFeePerGas is the total fee you are willing to pay per unit of gas. maxPriorityFeePerGas (which is sent to the miner) is the total priority fee you are willing to pay, which should be lower than or equal to the maxFeePerGas. How much you end up paying is gas × (baseFee + maxPriorityFeePerGas), assuming maxFeePerGas is higher than the current base fee. The difference between the maxFeePerGas and the actual used gas price is "refunded".

Legacy transactions will still work, but the gasPrice of legacy transactions will be used as both the maxFeePerGas and maxPriorityFeePerGas, so you'll never end up getting a refund. The miner will always take the difference between the base fee and the max fee. To get the full benefit of EIP-1559 it's recommended to set both fields.

For more details on how the max fees should be estimated or how EIP-1559 can be implemented in general, I recommend you check out the EIP-1559 Cheatsheet for Implementers.

3
  • 1
    Thanks for the explanation, but do you have any idea what web3.eth.getGasPrice() will return after this upgrade? will it give base fee or it will give the avg of maxFeePerGas? Aug 5, 2021 at 11:58
  • "assuming maxFeePerGas is lower than the current base fee", why would maxFeePerGas < baseFee ?
    – DiveInto
    Aug 6, 2021 at 14:10
  • That should've been "higher than the current base fee". Thanks for the comment.
    – Morten
    Aug 6, 2021 at 15:56

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.