Ethereum Private Chain Setup Guide

·

Installation

👉 Download Geth from the official website

Node Removal

geth removedb --datadir node1
geth removedb --datadir node2
geth removedb --datadir node3

Genesis Block Configuration (genesis.json)

{
  "config": {
    "chainId": 6666,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "ethash": {}
  },
  "nonce": "0x0",
  "timestamp": "0x5ddf8f3e",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0xffffffff",
  "difficulty": "0x0200",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {},
  "number": "0x0",
  "gasUsed": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

Key Parameters Explained:

Node Initialization

geth --datadir node1 init genesis.json
geth --datadir node2 init genesis.json

Troubleshooting: If genesis block initialization fails with:

unsupported fork ordering: eip150Block not enabled...

Run:

geth removedb --datadir node1

Then reinitialize.

Starting Nodes

geth --datadir "node1" --networkid 6666 --port 10010 --http --http.api "eth,net,web3,miner,admin" --http.addr "localhost" --http.port 8546 console 2>node1.log
geth --datadir "node2" --networkid 6666 --port 10011 --http --http.api "eth,net,web3,miner,admin" --http.addr "localhost" --http.port 8547 console 2>node2.log

👉 Essential tools for node management

Node Management

Account Operations

Transactions & Mining

FAQs

1. Why can't I unlock my account via HTTP?

Newer Geth versions disable HTTP unlocking by default for security. Use the --allow-insecure-unlock flag when starting nodes.

2. How do I set the beneficiary address for mining rewards?

miner.setEtherbase(account_address)

3. Why are my transactions not processing?

Transactions require mining. Start mining with miner.start() after submitting transactions.

4. How can I connect MetaMask to my private chain?

Add your network via MetaMask's "Custom RPC" option using the HTTP port (e.g., http://localhost:8546).

5. What's the purpose of chainId?

It prevents accidental cross-network connections. Ensure all nodes use the same ID.

👉 Advanced Ethereum development resources