-
Notifications
You must be signed in to change notification settings - Fork 10
geth account
When you first install Geth you will need to create a new account (unless you've simply copied accounts in your keystore directory from another system). Using the terminal (Mac/Linux) or Command prompt (Windows), type:
geth account new
When it launches, there will be a disclaimer to agree to, and you will be asked to enter a password for your local ethereum account. It will print an address and exit. You now have an ethereum address. Yay! But what just happened? Geth created an account file in something called the keystore directory. All accounts/wallets that you create will be placed in the keystore directory, regardless of which client you are using. For reference, it is stored within the main ethereum directory containing the other relevant files. It's a good idea to always make backups of your keystore directory:
Mac: ~/Library/Ethereum
Linux: ~/.ethereum
Windows: %APPDATA%/Ethereum
Now that we have a new account we want to put geth into action. For a full list of commands, type geth --help
(or visit here). If you just want to run geth and connect to the main ethereum network, simply type geth
or, if you want to enable geth with a javascript console, type geth console
. At the current blockchain size that will start downloading a 9GB data chain. For developers though, we want to connect to a test net where we can easily get some ether and test our contracts. To that we will connect either to the test-net or to our own local node.
Let us assume, however, that you have one computer for both development and daily operation. In this case you probably have the main 9GB chain downloaded, but you also want to do some test contracts before deploying to the main network. In this case, which I imagine is quite common, you will want to manage your test accounts and test blockchain separately from your main accounts. To do this we create a directory, say "testnet", and tell geth that that is where it should store its operations.
geth --datadir="~/testnet" account new
You have to make the testnet directory somewhere, and then point geth's datadir option to that directory. What this will do is create another ethereum directory for the keystore and chaindata files, and keep those separate from the default directory; you're essentially specifying a non-default directory.
We've included more in-depth instructions for deploying your own private blockchain in Local Node section of this wiki. The contract code that you write and deploy on your private testnet can also be deployed on the main ethereum network if you have purchased or acquired ether; in the meantime, testnet and private ether is free.