I have a question about setting gas prices after the new hardfork. Currently the software I'm working with uses the ethgasstation.info api to select a gas price and then publishes a raw transaction using Web3.py library using code something like this:

w3_tx = contract.functions.fn(hash_bytes).buildTransaction({"gas": 13000, "nonce": nonce_num, "from": from_addr})

gas_price = get_gas_price(gas_strategy) # Calls ethgasstation api
w3_tx["gasPrice"] = gas_price

signed = account.sign_transaction(w3_tx)

Will I have to change anything to specify the tips and the base fee for after the hardfork, or will this continue working without any problems?

1 Answer 1


Yes, the transaction format for EIP-1559 is different. The current transaction format (now called legacy transactions) will still work, but will result in you always overpaying for transactions.

Legacy transactions have a gas price, whereas EIP-1559 transactions have a priority fee and max fee. The max fee is how much you are willing to pay in total for your transaction (so base fee and the priority fee combined). If you send a legacy transaction, the specified gas price will be used for both the priority fee and max fee. This will result in you paying the full difference between the base fee and the set gas price to the miner, since you didn't set a lower priority fee.

How you get the priority fee will also likely change, and you shouldn't need an API like ETH Gas Station for this anymore, but how this should be calculated will probably wait until after the launch of EIP-1559.

Web3.py appears to support EIP-1559 already, and will try to determine the best max fee and priority fee: https://github.com/ethereum/web3.py/pull/2055

  • 1
    Nice, that web3.py code looks like lines 2-3 in @vividn above code, can be removed: web3.py automatically sets the priority and max fees.
    – eth
    Commented Jul 12, 2021 at 3:48
  • What will happen if use legacy? will it automatically deduct the base fee and extra will be considered as tip? Commented Aug 5, 2021 at 8:06
  • @ShubhamSingh Yes, see also my answer here where I explained this in more detail.
    – Morten
    Commented Aug 5, 2021 at 11:35
  • Great answer! Based on the merge request it seems that web3.py automatically computes the max fee, but still requires the priority fee to be specified. Commented Jan 1, 2022 at 8:24

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.