Sending entire Ethereum address balance in post EIP-1559 world

Question:

I’m trying to figure out how to send an entire address balance in a post EIP-1559 transaction (essentially emptying the wallet). Before the London fork, I could get the actual value as Total balance - (gasPrice * gas), but now it’s impossible to know the exact remaining balance after the transaction fees because the base fee is not known beforehand.

Is there an algorithm that would get me as close to the actual balance without going over? My end goal is to minimize the remaining Ether balance, which is essentially going to be wasted.

Asked By: Proto Ukr

||

Answers:

This can be done by setting the ‘Max Fee’ and the ‘Max Priority Fee’ to the same value. This will then use a deterministic amount of gas. Just be sure to set it high enough – comfortably well over and above the estimated ‘Base Fee’ to ensure it does not get stuck.

Answered By: Mark B
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.