Building a Private Ethereum Blockchain: Linux and Windows Guide

ยท

Background Knowledge

Ethereum is an open-source, decentralized blockchain platform featuring smart contract functionality. Its native cryptocurrency, Ether (ETH), powers the Ethereum Virtual Machine (EVM) for executing peer-to-peer contracts. Proposed in 2013-2014 by Vitalik Buterin, Ethereum was crowdfunded in 2014 as a "next-generation cryptocurrency and decentralized application platform."


Part 1: Linux Setup Guide (Ubuntu 16.04)

Prerequisites

Installation Steps

  1. Install Dependencies:

    sudo apt-get install software-properties-common
  2. Add Ethereum Repository:

    sudo add-apt-repository -y ppa:ethereum/ethereum
    sudo apt-get update
  3. Install Geth:

    sudo apt-get install ethereum
  4. Initialize Blockchain:

    • Create directories:

      mkdir Mychain && cd Mychain
      mkdir mydata
    • Generate genesis.json:

      {
        "config": {
          "chainId": 10,
          "homesteadBlock": 0,
          "eip150Block": 0,
          "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "eip155Block": 0,
          "eip158Block": 0,
          "byzantiumBlock": 0,
          "constantinopleBlock": 0,
          "petersburgBlock": 0,
          "istanbulBlock": 0,
          "ethash": {}
        },
        "nonce": "0x0",
        "timestamp": "0x5e4a53b2",
        "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "gasLimit": "0x47b760",
        "difficulty": "0x80000",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "coinbase": "0x0000000000000000000000000000000000000000",
        "alloc": {
          "0000000000000000000000000000000000000088": {
            "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
          }
        },
        "number": "0x0",
        "gasUsed": "0x0",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
      }
    • Initialize chain:

      geth --datadir mydata init genesis.json

Geth Console Operations

  1. Start Private Node:

    geth --identity "TestNode" --rpc --rpcport "8545" --datadir mydata --port "30303" --networkid 6666 --nodiscover console --allow-insecure-unlock
    • Flags explained:

      • --identity: Node identifier
      • --nodiscover: Disables peer discovery for private networks
  2. Account Management:

    • Create account:

      personal.newAccount("123")
    • List accounts:

      eth.accounts
  3. Mining:

    • Set miner address:

      miner.setEtherbase(eth.accounts[0])
    • Start/stop mining:

      miner.start()
      miner.stop()
  4. Transactions:

    • Check balances (Wei):

      eth.getBalance(eth.accounts[0])
    • Send ETH (unlock account first):

      personal.unlockAccount(eth.accounts[0])
      eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:web3.toWei(7,'ether')})
    • Process pending transactions:

      miner.start(1);admin.sleepBlocks(1);miner.stop();

Part 2: Windows Setup Guide

Prerequisites

Initialization

  1. Initialize genesis block:

    geth --datadir "%cd%\chain" init genesis.json
  2. Start node:

    geth --identity "TestNode" --rpc --rpcport "8545" --datadir chain --port "30303" --networkid 6666 --nodiscover console

GUI Wallet


FAQs

Q1: Why choose a private Ethereum chain?

A: Private chains allow testing smart contracts and dApps without using real ETH or exposing data to public networks.

Q2: How to speed up mining on a private chain?

A: Lower the difficulty in genesis.json to reduce computational requirements.

Q3: Can I connect Linux and Windows nodes?

A: Yes, ensure they share the same networkid and connect manually via admin.addPeer().

๐Ÿ‘‰ Explore advanced blockchain tools for enterprise solutions.

๐Ÿ‘‰ Learn about smart contract development with our developer guides.