3

I want to send ether from one account to another using the geth client. I don't want to wait several days or use up tens of gigs on my hard drive before doing so either. How can this be done?

3
  • Hi there. Can you reformulate your post into a question, please? At the minute it's unclear what you're asking, if anything at all :-) – Richard Horrocks Nov 6 '17 at 16:58
  • Is this still unclear in some way? I think it's pretty straightforward now... – sager89 Nov 9 '17 at 3:39
  • I have no idea why this got closed. It is a clear question with detailed steps for the answer. Almost seems like a blatant abuse of admin power. – sager89 Nov 17 '17 at 0:01
11
  1. Use light mode when starting geth. If you don't it will try and download the entire block chain, which uses a significant amount of space and could take days.

    To use light mode, do geth --syncmode "light"

  2. In another terminal, create a file with the following contents:

    function checkAllBalances() {
        var totalBal = 0;
        for (var acctNum in eth.accounts) {
            var acct = eth.accounts[acctNum];
            var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
            totalBal += parseFloat(acctBal);
            console.log("  eth.accounts[" + acctNum + "]: \t" + acct + " \tbalance: " + acctBal + " ether");
        }
        console.log("  Total balance: " + totalBal + " ether");
    };
    

    Note the path to this file as it will be needed later.

  3. Attach to the running geth instance with: geth attach

  4. Load the js from step 2 into the console with: loadScript("/path/to/file.js")

  5. Check your balance with: checkAllBalances(); Ensure you have enough both to send and cover the transaction cost. You may have to wait a few minutes for the light client to get the needed values.

  6. Unlock your account with personal.unlockAccount('yourAddressHere'); You will be prompted for your password. I prefer this approach to passing the password as a second parameter to the unlockAccount function as you don't ever have it in plain text.

  7. Send Ether with the eth.sendTransaction function, e.g. eth.sendTransaction({from:'fromAddress', to:'toAddress', value: web3.toWei(0.05, "ether"), gas:21000});

You should get a receipt value in hex. You can use web3.eth.getTransactionReceipt("receiptHash") to see details, with status of "0x1" meaning success. This may take some time. You can also use the receipt on sites like https://etherscan.io or https://etherchain.org to see details on the transaction by simply entering the hex value in the search bar on the respective site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.