How to determine maximum send amount? #2145
Unanswered
noahNewton
asked this question in
Q&A
Replies: 1 comment
-
You need to estimate the gas limit first: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to transfer the entire balance of ETH in our test wallet and I'm attempting to do this by subtracting the gas price from the total balance before sending and then sending that (balance - gasPrice) value in the "amount" param, but then I am faced with an error message that says: "insufficient funds or gas * price + value", what I am doing is subtracting the maxFeePerGas value from the amount value, so the actual params being sent would be {amount: (totalBalance - maxFeePerGas), maxFeePerGas: maxFeePerGas, ...restOfParams}, is there somewhere where I can find how your code is doing the (gas * price) + value calculation to see where maybe my gas calculation is off, though it is very close to the values on etherscan as I am using the latest block to derive the gas params, unsure what I'm doing wrong precisely.
Maybe to word this differently, how does trustwallet accomplish sending the entire balance in a transfer factoring in gas?
Beta Was this translation helpful? Give feedback.
All reactions