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.
0 ·
Comments
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 usingadmin.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: ... 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): 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/
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).