Account help

Hi everyone, I'm looking for a bit of help to do with accounts, I'm sure other people will find it helpful too.

If I create a VM for the first time and create a new Eth Address, mine for a while and have a little ether in the account, how do I export that address to another computer.

I've done it with Bitcoin in the past but seen as Ethereum is still in development it's not straight forward or I don't think it is.

Any help would be appreciated.

Comments

  • StephanTualStephanTual London, EnglandMember, Moderator Posts: 1,282 mod
    edited May 2015
    I'm going to assume you're using Geth, which is the recommend client for Olympic and the audited client that will form the Frontier release.

    Creating accounts and checking its balance

    When you start Geth for the first time, you will not have have an account ready, so you need to create it.

    Start geth in console mode (geth console) and then type:

    admin.newAccount()

    Have you Ethminers mine (if you don't understand what I mean by that, check this FAQ)

    After you mined a few blocks, you can check your balance using:

    web3.fromWei(eth.getBalance(eth.account[0]), "ether")

    By default in Geth, this account becomes your coinbase (ie, the account to which the mined Ether will be assigned, also known as 'etherbase'), so the following method call will return the exact same output:

    web3.fromWei(eth.getBalance(eth.coinbase), "ether")


    Checking multiple accounts

    You might have multiple accounts, as you can create new ones using admin.newAccount() as many times as you wish.

    In which case, you can list them using:

    eth.accounts

    ... and refer to each individual account by referencing them using array notation, as such:
    eth.accounts[0]
    eth.accounts[1]
    eth.accounts[2]
    ... etc

    Getting the balance for all the accounts at the same time is a little bit more involved: first, input this function at console (just paste it in):
    function checkAllBalances() { 
    	var i =0; 
    	eth.accounts.forEach( function(e){
        		console.log("  eth.accounts["+i+"]: " +  e + " \tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + " ether"); 
    	i++; 
    	})
    };
    Now you can invoke this function anytime during the session using:

    checkAllBalances()

    If you quit and restart Geth, you'll have to re-enter the function for it to work again.


    Transferring accounts or balances

    Method 1: copy the keys

    To transfer the entire key store to a different computer, you can copy the key files from one to the other (see https://forum.ethereum.org/discussion/2114/where-are-my-config-files-go-and-cpp for a list of key store locations). This works only between installs of Geth of course.

    Note that unlike Eth, Geth never exports the raw private keys - to be clear, you will never see them in plain text. The files you are transferring are encrypted private keys, which is a useful feature to have should you accidentally forget them on a USB stick for example :)

    The above method might be of importance to people who participated in Olympic and expect to receive a prize at Frontier Genesis - a python bot will assign the earned ether to the public/private key pairs automatically and therefore participants should insure they have kept access to their keyfiles.

    Another cool tidbit: you can do this *while* geth is running. Keys are just files!

    Method 2: use sendTransaction

    To transfer balances from account to account, wether on the same computer or a different one, you'll need to use the sendTransaction function: eth.sendTransaction({from:sender, to:receiver, value: amount}). Note that this will cost you a bit of Ether in gas costs.

    You can set parameters ahead of time in the console, or you can send the whole command in one line, for example:

    eth.sendTransaction({from:eth.accounts[0], to:'f9d4626f6a03c3756657a38354954f44d54bc5df', value: web3.toWei(1.99, "ether")})


    Note that the excellent Frontier Guide has a little bit more information: http://ethereum.gitbooks.io/frontier-guide/content/

    Post edited by StephanTual on
  • Maren85Maren85 Member Posts: 41
    Fantastic post, thanks very much!
  • Brillopad12Brillopad12 Member Posts: 17
    I had my computer crash on me before I had copied the keys. Only one account had some ether in it. I have my address and the pass phrase I used when I created the account. Can I recover it? Or is it lost? Using Geth on Unbuntu. Any help would be appreciated. Thanks again
  • Maren85Maren85 Member Posts: 41
    It doesn't really matter as the Ether is useless at this point.
  • Brillopad12Brillopad12 Member Posts: 17
    It was mainly to get the mining reward when Frontier launches.
  • Maren85Maren85 Member Posts: 41
    Theres no guaranteed reward, I'm sure I read that any rewards will be distributed at their discretion, not just for everyone, if you've only got a small amount I wouldn't be concerned.
  • Brillopad12Brillopad12 Member Posts: 17
    That account mined about 220 blocks. That should be about 100 ether. I would love to be able to recover it.
  • Maren85Maren85 Member Posts: 41
    If you can access the computer then it can be recovered following StephanTual's instructions, if you can't then it can't, quite straight forward really.
  • StephanTualStephanTual London, EnglandMember, Moderator Posts: 1,282 mod
    If you lost your keys, you lost access to the account and its ether balance, permanently. Private keys cannot be generated from public ones (obviously) and the password is just a means to encrypt the private key that was accidentally deleted, not regenerate it.
  • Brillopad12Brillopad12 Member Posts: 17
    edited May 2015
    @stephantual Thank you for the update. I would recommend adding the Method 1 from above to your mining guide when you show how to backup the blockchain etc. to help prevent others from making my same mistake. :'(
  • deliveryyyyguydeliveryyyyguy Member Posts: 8
    where did my private keys get stored? Im ganna freak out.
  • Xai290xXai290x Member Posts: 1
    ATTENTION: Please correct the following which is incorrect, as it was very annoying to figure out for me.
    web3.fromWei(eth.getBalance(eth.account[0]), "ether") <-- that is incorrect
    web3.fromWei(eth.getBalance(eth.accounts[0]), "ether") <-- that is correct
    The s at the end of eth.account makes the world of difference lol. Now I can check my different accounts without using the js function, because cmd prompt and copy/paste don't get along too well for me(for some reason right click is paste and it rarely works).
Sign In or Register to comment.