send all native tokens from a wallet, EIP-1559 #4161
Replies: 1 comment 6 replies
-
Heya! So, clearing out an EOA account without leaving any dust is not really possible outside some incredible luck in Ethereum with EIP-1559, but I’ll go into a little more detail. First of all though, the fact you are using If the gas limit isn’t 21000, I’m guessing that either the too dress is a contract, that an access list is specified, data is included in the transaction, or something along those lines. There are lots of reasons Ethereum charges extra fees, but it should be 21000 for transferring from an EOA to another EOA. The reason draining an account is difficult in EIP-1559 is that the baseFee used is protocol-defined and moves up and down in every block. And if you provide a maxFeePerGas equal to the current baseFee, and the next block goes up (50% chance) then your tx will have insufficient funds. If it goes down, dust. The general rule-of-thumb is to use 2x the current blocks baseFee, but the next block can only increase by a maximum of 12.5%. But in the even of contention for block space, you might have to wait more than one block, so even if you provide 12.5% extra, after two blocks, each block could have raised it 12.5% (for a total of 26.5%), so now your fee becomes insufficient again. Basically, a dust free transfer is near impossible without knowing the future. Does that make sense? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I think I'm doing everything (at least almost) correctly but still I get an error
"insufficient funds for gas * price + value:"
I want to send all ETH a wallet has to another wallet. So I guess I should just subtract the fees from the value right?
theAmount is in ether so I think everything is ok and also in ether
example
theAmount 0.001387691715564448
subTractForGas 0.0000021000000000000002
allAssets 0.0013855917155644478
but the example is from the time I multiplied gasPrice by 21000 and got the error so I thought I should estimate the gas myself, but it didn't fix the issue tho the number was much higher ~400000

UPD it works if I add gaslimit: estimateGas and gasPrice params to the tx... but this is not how it suppose to be for the EIP 1559 transactions right?
also why is estimateGas is not equal to 21000 ?....
I've googled that for the EIP 1559 tx I need to add and put the same values for maxFeePerGas and maxPriorityFeePerGas. but first of all it doesn't work, and the second is ehmm... well you've told that the ethers js sets the maxPriorityFeePerGas always to 1 gwei and it seems to be enough for everything? so obviously if to set the maxFeePerGas to 1 gwei, no tx will be sent, and then for example if the gasPrice is 50 gwei why does anybody need to increase the maxPriorityFeePerGas to 50 gwei just for sending the same values in both params? Sounds weird and doesn't work for me in the first place... Could you please explain how to do it correctly? Sending all native token balance from one wallet to another one? Thank you:)
Beta Was this translation helpful? Give feedback.
All reactions