-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
erc20 transfer out of gas errors when sending max tokens #8136
Comments
I have now also reproduced this for GST2. |
This issue seems to only affect transfers. |
Sine we call The most ideal reproduction would be to open the background network inspector, and With that request, Infura and geth team members will be able to trace why the estimate is low. |
@wjmelements Would you be willing to hop on a quick call to help us replicate this issue? We're having trouble recreating it. Do you have Telegram or some other medium I can use to contact you directly? |
I can still 100% repro on 7.7.7.
I don't think metamask does that. Probably your estimate gas params are wrong.
I have the same username on most platforms |
Is this by using the Max Button? |
I have found your bug, you are estimating gas with value=0 in the transfer |
Value is determined in the data hex for token transfers. |
As seen in the data, it is 0 |
There are no subsequent calls to eth_estimateGas after the estimate with transfer of 0, so that is the issue. You have to re-estimate with the correct transfer value. A transfer of 0 will not change the 0-ness in the SSTORE when the recipient has no tokens. |
Hmm I am fairly certain we update data on input change, otherwise we would see numerous other issues, but ill investigate that a little more. Can you clarify on what what method those params are for, I am guessing its for eth_estimateGas? |
right |
Also, note how the "Send Amount" shows 100% of my ETH instead of 100% of my MKR in the penultimate screenshot. I don't think that manifests in the TX but it's still fairly scary to think you might be sending all my ETH to the MKR token contract. |
I have verified that you do when I type in the value, but you do not when the Max button is pressed instead. |
Fixed by #8176. Will get it out in the next release thanks for the report and investigation. |
Version 7.7.2
I've twice seen erc20 out of gas errors when transferring tokens on mainnet. The two tokens were USDC and WETH. What the failures had in common was that the gas estimation seemed to not take into account that the recipient had no prior balance, so the SSTORE cost 20000 instead of 5000. This can also happen if the recipient empties their balance before the transfer confirms but that wasn't true this case.
In both cases I was sending the entire token balance of my account.
I did not see a similar issue when I was transferring ETH to the WETH contract, which created WETH for an account that had none.
The workaround is to manually set the gas limit in Advanced.
The text was updated successfully, but these errors were encountered: