using geth attach, already unlocked "from" account, then i issue the following command
eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:eth.getBalance(eth.accounts[0])})
but it said : Insufficient funds for gas * price + value
how to calculate maximum amount i can send? can't it just do it automatically?
0 ·
Comments
Usually the gas amount is picked up by default, like when you call sendTransaction like this. But since you send all your ether, there will be nothing left on the account to pay for the gas.
So you need a slightly more involved process, such that you send exactly all the funds minus the gas required for the transaction, and specify that gas to be used.
Please consult this QA: https://ethereum.stackexchange.com/questions/961/mist-how-to-send-all-coins-in-account
eth.sendTransaction({from:'0xADDRESS',to:'0xRECIPIENT',value:eth.getBalance('0xADDRESS')-21000*50000000000-1,gas:21000,gasPrice:50000000000})
Note the two extra parameters gas and gasPrice at the end. Here the
value
we send is computed from the total balance minus the gas, minus 1 to account for a rounding error.In this example the gasPrice is 50 shannon although it should be OK for it to be as low as 20 shannon.