6

Two situations.

  1. You want to transfer all the money in an account and want to compute the right amount of gas and tax suc that you transfer all that is possible and leave the account with 0.

  2. You want to transfer a specific amount of money and want to compute the right amount of gas and tax such that you transfer exactly the desired amount.

How do you compute both values?

4

The second is simpler, the gas fees are deducted from your account, not from the transferred value, so you need only to specify 21K gas (transaction cost) * 50 shannon (minimum gas price currently).

To sweep your account, you need to calculate the transaction cost (21K gas * 50 shannon), and send your total balance - costs. That will leave your account at 0 balance.

4

As discussed by Tjaden Hess here you need to multiply gas amount with gas price and substract a single wei on top of that (not sure why).

You can specify the amount of 21,000 gas and the gas price of 50 shannon:

{from:'0xACCOUNT', to:'0xRECIPIENT', value:eth.getBalance('0xACCOUNT') - 21000 * 50000000000 - 1, gas:21000, gasPrice:50000000000}

Note, that in the mist ethereum wallet, you have issues with rounding of all the decimals. Using a command line interface like geth is recommended to figure out the exact amounts.


The gas price is a moving target. If this is not working you could also use the transaction cost calculator for Ethereum.

  • 1
    Neither of you told me how do I find those numbers (21000 and 50). I've just attempted that, but the transfer isn't going... – MaiaVictor Feb 4 '16 at 17:12
  • 1
    From Ethereum Yellow Paper, 21000 is Gtransaction in Appendix G. Gas price of 50 shannon is asked at ethereum.stackexchange.com/q/324/42. – eth Feb 4 '16 at 18:24

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.