Build Ethereum Private Network Properly

This section describes how to build a new Ethereum private network properly.

With everything we have learned so far, let's build a new private Ethereum network with those 6 step given in the previous tutorial.

1. Decide a "datadir" folder and network ID for the new network. If that folder exists, delete it.

--networkid 314
--datadir \herong\Ethereum\personal

C:\>rmdir /s /q \herong\Ethereum\personal

2. Create the first Ethereum account in the "datadir" folder to hold the pre-allocated Ether fund:

C:\>"\Program Files\Geth\geth" --datadir \herong\ethereum\personal
   account new
  
Maximum peer count   ETH=25 LES=0 total=25
Your new account is locked with a password. Please give a password. 
Do not forget this password.
Passphrase: ******
Repeat passphrase: ******
Address: {05d4e1a499775ce9d681abd50bda655c7b5ccb90}

3. Create a genesis block file in JSON format with some Ether fund allocated to the first Ethereum account and a reasonable mining difficulty level.

C:\>type \herong\ethereum\personal\genesis.json 

{
    "config": {
        "chainId": 314,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "10000000",
    "gasLimit": "10000000",
    "alloc": {
        "05d4e1a499775ce9d681abd50bda655c7b5ccb90": 
           { "balance": "10000000000000000000000000" }
    }
}

4. Initialize the blockchain with the genesis block file.

C:\>"\Program Files\geth\geth" 
   --datadir \herong\Ethereum\personal
   init \herong\ethereum\personal\genesis.json 

5. Start the Ethereum node.

C:\>"\Program Files\geth\geth" 
   --datadir \herong\Ethereum\personal
   console 2>> geth-personal.log

6. Start the Ethereum miner. It will set the Etherbase, or coinbase, to the Ether account used in the genesis block.

> eth.coinbase
"0x05d4e1a499775ce9d681abd50bda655c7b5ccb90"

> miner.start(1)
null

My private network is up and running! Now wait and watch the balances of the Ether account:

> web3.fromWei(eth.getBalance(eth.coinbase),"ether")
10000000

> eth.blockNumber
1

> web3.fromWei(eth.getBalance(eth.coinbase),"ether")
10000005

...

Wonderful! My Ether account has 10M Ether received from the genesis block pre-allocation. The balance is increasing with mining rewards received from mining new blocks.

Table of Contents

 About This Book

 Introduction of Ethereum

 Ethereum Blockchain

 Ethereum Mist Wallet

 geth - Go Ethereum

 Deprecated: Testnet - Ropsten Network

 Private Ethereum Network

 64-Bit "geth" for Private Ethereum Network

Private Network with Custom Genesis Block

 Transferring Funds between Ether Accounts

 MetaMask - Browser Based Ethereum Wallet

 Using MetaMask Wallet

 Getting Free Ether on Test Networks

 Managing Ethereum Account

 Mining Ether with Your Computer

 Archived Tutorials

 References

 Full Version in PDF/EPUB