2

I'll have a large of wallets, potentially, from which I'll be needing to withdraw ETH, and tokens, from time to time to the central, admin wallet. By a script, once a week.

Instead of having to calculate the gas fee for each wallet, in case of ETH, each time, dynamically, wouldn't it be simpler to:

  • a) create a constant, let's say, MIN_VALUE_TO_HOLD_FOR_GAS = 0,001
  • b) substract it off the balance
  • c) send the rest to the admin wallet

?

At the moment 0,001 is approximately $2 USD. This will be more than enough to pay for gas fee and there'll be something left as well.

 let balance2 = balance - ethers.utils.formatUnits(MIN_VALUE_TO_HOLD_FOR_GAS, "gwei");
 const tx = await wallet.sendTransaction({
      to: account,
      value: balance2,
 })

 const receipt = await tx.wait()

Meaning, it want to get rid of the necessity to calcuate the gas fees each time.

Is there any flaw in this approach? Or will it be better to calcuate the gas fees and substract them, dynamically, still?

I'm using ethers.js

0

Your Answer

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