I'm trying to send all of my ETH balance to another address. I try to do this the following way, but always receive an error:
[~] $ geth attach ipc:~/.ethereum/geth.ipc
WARN [06-21|15:26:14.974] Enabling deprecated personal namespace
Welcome to the Geth JavaScript console!
instance: Geth/v1.14.5-stable-0dd173a7/linux-amd64/go1.22.4
at block: 20140386 (Fri Jun 21 2024 15:26:11 GMT+0200 (CEST))
datadir: /home/svandijk/.ethereum
modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
To exit, press ctrl-d or type exit
>txh = eth.sendTransaction({from: eth.accounts[0], to: [targetadd, not sure if this is sensitive info], value: eth.getBalance(eth.accounts[0]).sub(web3.eth.gasPrice.mul(21000))});
Error: gas required exceeds allowance (10501)
at web3.js:6387:9(39)
at send (web3.js:5116:62(29))
at <eval>:1:26(27)
The idea being to send (balance - gasprice * 21000), leaving enough to cover the transaction fees. I'm not sure what the error means, what is the 'allowance'? And what is the number between the brackets (10501)?
I thought maybe I was making a mistake in calculating the amount I can transfer, and subtracted more (to have more left over for higher transaction fees). But even when subtracting (gasprice * 31000), I get the same error (and a higher number between the brackets).
In case it wasn't obvious, I'm a total noob in Ethereum and crypto in general, so I apologize if I'm asking something stupid. Thanks!