In this video we’ll install geth, create a local network, and create our first Ethereum account.
To download geth head on over to the download page and download the binary for your system.
When you unzip it, you should have a binary named
geth, which you need to save somewhere:
mkdir -p ~/courses/newline-web3 cd ~/courses/newline-web3 mkdir bin cp geth ./bin/geth
Now that we have
geth, we need to do some initial configuration.
For our private node we are not joining the production Ethereum network. We’re not going to download the history of everything that has happened in Ethereum thus far. Instead, we’re going to start our own private network. We’re going to start with a clean slate.
This clean slate means that we are creating our own blockchain. I know that we haven’t talked about what a blockchain is or how it works, but we will. For now, just think of it like your test database and your production database – you can’t just merge your test database into your production database and expect it to work.
Similarly, changes to our local Ethereum blockchain will have no effect on the production Ethereum network.
We’re going to configure our local test blockchain by using this configuration file,
genesis.json. You can get a copy of this file from the lesson notes.
Each of these configuration parameters will make sense in time, but for now, just copy this file and save it as
When we boot
geth it is going to save it’s “database” in a folder on our disk. This folder saves the state of our blockchain, and more importantly, the keys to our accounts. We will specify this folder every time we boot our
Let’s initialize our node now:
./bin/geth --datadir=./datadir init genesis.json ls tree datadir
We can see that
datadir was created for us and it contains two folders:
geth directory holds our blockchain data. The
keystore directory, will hold our accounts keys, once we have them.
geth contains a number of commands and options. We can see the list by running
./bin/geth --help | more
One of the first things we’re going to need are accounts. We can create an account like so:
./bin/geth --datadir=./datadir account new # abc123
We’re going to need this password later, so I’m just going use the password
abc123. Obviously, you need to use a strong password when you start handling real funds.
Notice that when we created this account, it output an address, which is this long string of characters. This is your receiving address – it’s okay for it to be shared publicly.
We can now see it in our list of accounts, by calling
./bin/geth --datadir=./datadir account list
And now if we look at datadir:
You can see that we have a new file in keystore.
cat datadir/keystore/UTC--2017-07-24T17-24-51.466085765Z--a91aaf38a9020d893e2f94e42f8060b7ee70026c # I'm going to pipe it through jq for readability cat datadir/keystore/UTC--2017-07-24T17-24-51.466085765Z--a91aaf38a9020d893e2f94e42f8060b7ee70026c | jq '.'
Here is our “address” and a variety of other parameters. While the address can be publicly shared, the rest of it needs to remain secret. If someone had the information in this file, they would be able to steal all Ethereum controlled by this account.
There’s another important and interesting thing you should know about accounts: they’re generated completely offline.
When you create an account with Facebook, you’ll hit Facebook’s servers and they’ll create an account in their database which you can use. When you create a traditional bank account, you go to your bank, prove your identity, ask them to create an account for you, and they create an account in their database and they let you use it.
Ethereum accounts (and Bitcoin, too) are generated from an algorithm, completely offline. You’re not hitting a remote server to generate this address. In fact, no one knows that this address even exists until it’s part of a transaction in the network.
In one sense, you’re just picking an address at random out of a huge pool of possible addresses.
If you’re familiar with SSH, it’s a lot like generating SSH-keys – you don’t ask for permission from a central server to generate SSH keys – you generate it from randomness and an algorithm on your computer.
So generate as many addresses as you need – just make sure you securely backup your private keys.