0

Say I have received an ERC20 token in my address. Such address has no ETH and no other tokens except the one I just received. If I try to estimate the gas cost of sending the token from that address, the mocked transaction fails because there's not enough gas to run the simulation.

I need the gas estimation in order to know approximately how much ETH I have to send from another address in order to collect the ERC20 funds, but I cannot run the estimation because I have no ETH... so it's a cyclic problem.

Any known solution for this problem?

  • What is the ERC20 token address? – goodvibration Feb 14 at 15:37
  • DAI, for instance: etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f Actually it doesn't really matter, this question could be applicable to any function one would like to estimate. – Molina Feb 14 at 15:38
  • 1
    Yes it does, because different tokens may implement different transfer functions with different gas costs. – goodvibration Feb 14 at 15:39
  • And AFAIK, you don't need ether in order to run estimateGas. Most likely, the function that you are trying to estimate requires some condition which doesn't hold for your given input. – goodvibration Feb 14 at 15:42
  • Regardless of the token's transfer function it will have a gas cost strictly greater than zero, so the simulation will fail in all cases since the address I'm running the simulation from has zero ETH. Isn't it the case? – Molina Feb 14 at 15:43
1

You don't need ether in order to run estimateGas.

The only reason for estimateGas to revert is if the function which is being estimated reverts.

In other words, the function that you are trying to estimate gas for (function transfer I assume), requires some condition which doesn't hold for the input that you are passing to it when you execute the transaction).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.