0

For the context (can be skipped) : I have some deposit accounts containing some ERC20 token but no ETH. I would like to send all this ERC20 to a main account. In order to do that, I need to send ETH to these deposit account (to pay for the gas fee for the ERC20 transfer). But I don't want to waste ETH (there may be hundred of account a month).

So, my question is : Is there a way to estimate the gas amount needed for a transaction without needing to have ETH in the account ?

What I have already tried : Using the ethers.js library I tried with the following command -> let contract = new ethers.Contract(contractAddress, abi, signerNewAddress);let estimation = await contract.estimateGas.transfer(signerOwner.address, ethers.utils.parseUnits("100",decimalNumber); With contractAddress : the ERC20 address, signerNewAddress : a deposit account address and signerOwner : the account where I want to send the ERC20 token. Unfortunately, because the signerNew address doesn't have any ETH I get the following error : Error: cannot estimate gas; transaction may fail or may require manual gas limit

1 Answer 1

0

I made a mistake. The contract.estimateGas.transfer works even if no ETH on the account. My error was that I didn't have enough ERC20 token at that address.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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