Will I have to change how I set raw transaction gas price for eip-1559?

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?

Answers 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

Related Questions