I have an ethereum wallet, I need to calculate the amount to completely empty the wallet.

So currently i calculate the needed gas like this,

needed_gas = w3.eth.gasprice * 210000

amount_to_send = balance - needed_gas

However, the are still few cents remaining in the account, this causes a loop as I try to transfer untill the amount_to_send value is 0.

  • 1
    Change 210000 to 21000. – goodvibration Mar 14 '19 at 7:44
  • I tried this, now I get an out of gas error. The amount in my wallet was 0.65245773 After using the above the logic, I tried to transfer 0.065204958 – Paras Mar 16 '19 at 16:35

Your Answer

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

Browse other questions tagged or ask your own question.