# How do you compute the right amount of gas and tax to transfer certain amount of money?

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?

• – eth
Jul 29, 2016 at 1:32

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.

• Currently, it appears that in geth there is a bug that does not allow reducing the balance to 0, you need to leave 1 Wei. Feb 4, 2016 at 16:56
• Actually, it's a rounding error in the JS console. See github.com/ethereum/go-ethereum/issues/… Feb 16, 2016 at 0:31

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.

• 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... Feb 4, 2016 at 17:12
• 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, 2016 at 18:24