BlockchainTutorialTutorials

The following instructions walk through the installation of a single node private installation of an Ethereum blockchain using the Go-Ethereum client.

Prerequisite:
Ubuntu 16.04 Virtual Machine (either on realCloud or as realcloud VM)

Step 1: Update Ubuntu installation with the latest packages

sudo apt-get update
sudo apt-get -y upgrade

Step 2: Install golang-go package

wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
sudo tar -xvf go1.7.4.linux-amd64.tar.gz
sudo mv go /usr/local
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Step 3: Build go-ethereum from github

git clone https://github.com/ethereum/go-ethereum.git ~/go-ethereum
cd ~/go-ethereum
git checkout master
make geth
cd ~

Step 4: Test geth installation

go-ethereum/build/bin/geth version

Expect a response similar to:

Geth
Version: 1.6.1-unstable
Git Commit: e353f9c0886f0cc13fd01c8b3abf2fa63025c62f
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.7.5
Operating System: linux
GOPATH=
GOROOT=/usr/local/go

Step 5: Create an account to use as the coinbase for your blockchain node

An Ethereum account is the public key that stores ether that will be used in your private blockchain to pay for gas fees. Before we start the blockchain, we need to create an account that the mining rewards will be deposited too.

go-ethereum/build/bin/geth account new

You will be prompted to set a password for the account, DON’T FORGET YOUR PASSWORD, you will not be able to recover it later and won’t be able to spend the ether you mine or unlock that account. After entering the password twice, you should expect to get a response back like this:

Address: {941f1f0b08757457be0b52d83a1e3e566473ed61}

This is the public key of the Ethereum account. Ethereum convention is to prefix accounts with 0x so the account is sometimes seen as 0x941f1fobo8757457be0b52d83a1e3e566473ed61.

Step 6: Create JSON File for Genesis Block to Bootstrap Private Blockchain

Using a text editor, create a file CustomGenesis.json with the following contents:

{
    "config": {
        "chainId": 13,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "200000000",
    "gasLimit": "2100000",
    "alloc": {
        "941f1f0b08757457be0b52d83a1e3e566473ed61": { "balance": "100000000" }
    }
}

Step 7: Initialize the blockchain from your CustomGenesis.json file

go-ethereum/build/bin/geth init ./CustomGenesis.json

You should expect to see output similar to this:

INFO[02–23|20:20:03] Allotted 128MB cache and 1024 file handles to /home/ubuntu/.ethereum/geth/chaindata 
INFO[02–23|20:20:04] closed db:/home/ubuntu/.ethereum/geth/chaindata 
INFO[02–23|20:20:04] Allotted 128MB cache and 1024 file handles to /home/ubuntu/.ethereum/geth/chaindata 
INFO[02–23|20:20:04] successfully wrote genesis block and/or chain rule set: 5dd3be94dcbf5216aaa3e82700fb51a831257df5d45d984941a0a32ee0f960d8

Congratulations! You have initialized a private Ethereum blockchain!!

Start the discussion at community.bamboozle.me