Building an Ethereum Private Chain with Geth on Windows 10: A Step-by-Step Guide to Visual Wallet Integration and Mining

·

Introduction

This guide provides a comprehensive walkthrough for setting up an Ethereum private chain using Geth on Windows 10, connecting to MetaMask as a visual wallet, and initiating mining operations.


1. Installing the Geth Client

Download and Installation Steps

  1. Download Geth:

  2. Installation:

    • Run the installer and choose a preferred directory.
    • Note: Disable proxy/VPN if downloads fail.
  3. Verification:

    • Open Command Prompt (cmd) and execute:

      geth -help
    • Successful installation displays a help menu.

2. Configuring the Genesis Block

Create genesis.json File

{
  "config": {
    "chainId": 8434,
    "homesteadBlock": 1,
    "eip150Block": 2,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 3,
    "eip158Block": 3,
    "byzantiumBlock": 4,
    "alien": {
      "period": 2,
      "epoch": 300,
      "maxSignersCount": 5,
      "minVoterBalance": 100000000000000000000,
      "genesisTimestamp": 1536136198,
      "signers": [
        "0x393faea80893ba357db03c03ee73ad3e31257469",
        "0x30d342865deef24ac6b3ec2f3f8dba5109351571",
        "0xd410f95ede1d2da66b1870ac671cc18b66a97778"
      ]
    }
  },
  "nonce": "0x0",
  "timestamp": "0x5b8f92c2",
  "extraData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x47b760",
  "difficulty": "0x1",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
    "cbfc29c31a31c869f9eb59a084d9019965978a7e": {
      "balance": "0x31d450f18af132720000000"
    },
    "393faea80893ba357db03c03ee73ad3e31257469": {
      "balance": "0xd3c21bcecceda1000000"
    },
    "30d342865deef24ac6b3ec2f3f8dba5109351571": {
      "balance": "0xd3c21bcecceda1000000"
    },
    "d410f95ede1d2da66b1870ac671cc18b66a97778": {
      "balance": "0xd3c21bcecceda1000000"
    },
    "a25dc63609ea7ea999033e062f2ace42231c0b69": {
      "balance": "0xd3c21bcecceda1000000"
    }
  },
  "number": "0x0",
  "gasUsed": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

Key Parameters Explained

ParameterPurpose
chainIdUnique network ID (avoid conflicts with public chains).
difficultySets mining difficulty (lower values ease CPU mining).
allocPre-funds accounts with Ether (in wei).
gasLimitMaximum gas per block (set high for private chains).

3. Initializing the Private Chain

Run in Command Prompt:

geth --datadir .\db init genesis.json

4. Starting the Node

Execute:

geth --http --http.api db,eth,net,web3,personal --datadir .\db --networkid 1997 console 2>> log2020526.log

Flags:

Verify node status with:

admin.nodeInfo

5. Creating Accounts

Steps:

  1. Check existing accounts:

    eth.accounts
  2. Create a new account:

    personal.newAccount()
    • Set a secure password.
  3. Check balance:

    eth.getBalance(eth.accounts[0])

6. Connecting MetaMask

  1. Install MetaMask (Chrome extension).
  2. Configure Network:

    • Select Localhost 8545 in MetaMask.
  3. Import Account:

    • Export private key from MetaMask (Settings > Export Private Key).
    • Import into Geth:

      geth account import /path/to/private_key.txt
    • Move the generated file to keystore.

7. Mining Ether

Commands:


FAQs

Q1: Why is my Geth installation failing?

A: Ensure proxies/VPNs are disabled during download.

Q2: How do I reset my private chain?

A: Delete the db folder and reinitialize genesis.json.

Q3: Can I change the mining difficulty later?

A: Yes, modify difficulty in genesis.json and reinitialize.


Conclusion

This guide covers private chain setup, wallet integration, and mining. For advanced configurations, explore Geth documentation.

👉 Explore advanced Ethereum tools