Create an Ethereum Private Network

Iblockchain
4 min readDec 24, 2019

Nowadays, Blockchain is not only a buzzword but has many operational solutions in the industry. In my opinion, the best way to learn and understand the capabilities of this technology is by implementing your own private production ready Blockchain. in this technical article i will test an implementation of a blockchain solution .

Let’s start by showing how demonstrate how to operate it.

Firstly installing the Ethereum requirements:

For MacOs users

brew tap ethereum/ethereum
brew install ethereum

For Linux users

To enable our launchpad repository run:

sudo add-apt-repository -y ppa:ethereum/ethereum

Then install the stable version of go-ethereum:

sudo apt-get update
sudo apt-get install ethereum

Or the develop version via:

sudo apt-get update
sudo apt-get install ethereum-unstable

Once finished, you can run in a new terminal the geth command as follows:

Geth command line

So now we have ethereum installed, let’s create our nodes.

Create a new directory and place the path to bc-usecase like below

mkdir ~/bc-usecase & cd ~/bc-usecase

create node0

mkdir node0 
geth — datadir node0/ account new

after this you type a password and save in in password.txt file in node0 folder

create node1

mkdir node1
geth — datadir node1/ account new

after this you type a password and save in password.txt file in node1 folder

the same for the node0 save the public address of the key in addresses file

Create a genesis block

To create a genesis block you have to type the command bellow and follow the instructions:

->puppeth

1. First choose a network name

2. Configure new genesis

3. choose Clique - proof-of-authority

4. keep it to default

5. add addresses of the two nodes it must be stated with 0x

> 0xe1EF2A0585960772dfaE242555a6B22190Cd0F83> 0x0801215C76ed9B336b405551635ED309a7055817

6. Which accounts should be pre-funded? (advisable at least one)

> 0xe1EF2A0585960772dfaE242555a6B22190Cd0F83

7. Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes)

8. Specify your chain/network ID if you want an explicit one (default = random)

> 201901

9. you will need to export the genesis block

INFO [11-10|20:09:48.500] Configured new genesis blockWhat would you like to do? (default = stats)1. Show network stats2. Manage existing genesis3. Track new remote server4. Deploy network components

> choose 2

1. Modify existing configurations2. Export genesis configurations3. Remove genesis configuration

> choose 2 to export the genesis block

Which folder to save the genesis specs into? (default = current)Will create admin.json, admin-aleth.json, admin-harmony.json, admin-parity.jsonINFO [11-10|20:10:22.633] Saved native genesis chain spec          path=admin.jsonERROR[11-10|20:10:22.633] Failed to create Aleth chain spec        err="unsupported consensus engine"ERROR[11-10|20:10:22.633] Failed to create Parity chain spec       err="unsupported consensus engine"INFO [11-10|20:10:22.635] Saved genesis chain spec                 client=harmony path=admin-harmony.json

The next step is to init our nodes with the genesis block

geth — datadir node0/ init admin.json
geth — datadir node1/ init admin.json

Now when a tool that with synchronise our nodes, for this reasons we need to use bootnode

let start but initialise it

bootnode -genkey boot.key

now we can start our bootnode

bootnode -nodekey boot.key -verbosity 9 -addr :30310

Let’s start our nodes

geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --rpcapi 'cmd, accounts, internal, node, rpc, signer: insecure unlock protect' --bootnodes 'enode://a8f363f7ecc5d258bfdd0c1022cd31c9f29b337c0e923a98099d70d585dd7ac5e42136dfb238c778fc4aac28389f4b4d4a8876af2f3408a0b5702d4ceee0d209@127.0.0.1:0?discport=30310' --networkid 201901 --gasprice '0' -unlock '0x0801215C76ed9B336b405551635ED309a7055817' --password node1/password.txt --mine --allow-insecure-unlockgeth --datadir node0/ --syncmode 'full' --port 30312 --rpc --rpcaddr 'localhost' --rpcport 8503 --rpcapi 'cmd, accounts, internal, node, rpc, signer: insecure unlock protect' --bootnodes 'enode://a8f363f7ecc5d258bfdd0c1022cd31c9f29b337c0e923a98099d70d585dd7ac5e42136dfb238c778fc4aac28389f4b4d4a8876af2f3408a0b5702d4ceee0d209@127.0.0.1:0?discport=30310' --networkid 201901 --gasprice '0' -unlock '0xe1EF2A0585960772dfaE242555a6B22190Cd0F83' --password node0/password.txt --mine --allow-insecure-unlock

let’s test the connection to node0

Everything is going good we get at the end the network version.

--

--