Estimating contract execution price in ETH #3336
Unanswered
herocode-it
asked this question in
Q&A
Replies: 1 comment
-
Units of Hence multiplication of these two things will yield const txEthAmount = functionGasFees.mul(feeData.maxFeePerGas) // not txGasPrice
console.log(formatEther(txEthAmount)); // 0.0000730050009734 |
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.
-
Hello.
I'd like to send all available USDC tokens from my wallet to another address (basically sweep them).
My wallet only has USDC, no ETH - so to execute the transfer I need to send myself some ETH from another wallet, so I have funds to cover the gas.
I don't want to send too much, otherwise the unused ETH will be wasted.
I've read that I need to multiply gas times maxFee, so I try to estimate the fee using
contract.estimateGas.transfer
and then multiply it withfeeData.maxFeePerGas
, however the resulting value does not make sense.For example:
48670 * 1500000020 = 73005000973400 (73005 Gwei)
, but I see on Etherscan that similar transaction sent at the same time used only0.000655 Gwei
. It seems that the gas estimate is okay, but thefeeData.maxFeePerGas
is way too big?My code (I'm using goerli for testing)
Output:
Can anyone tell me what I am doing wrong? Huge thanks.
Beta Was this translation helpful? Give feedback.
All reactions