How to Build and Deploy an Ethereum Private Chain on Blockchain?

·

Trusted e-certificates utilize permissioned blockchains as their underlying technology. For simplicity, this guide focuses on private chains, explaining how to set up and deploy your own Ethereum private chain.

Environment Setup

Hardware Requirements


Step-by-Step Guide

Step 1: Deploy the Master Node (Genesis Block Creation)

  1. Start Geth Service
    Launch Geth with interactive console:

    geth console
  2. Create a New User
    Use the Web3 interface to register:

    personal.newAccount("test1234");
    • Note the generated public address (e.g., 0xfc3147...), required for genesis configuration.
  3. Exit Geth
    Avoid unnecessary public chain synchronization:

    exit
  4. Configure Genesis Block
    Create genesis.json with these parameters:

    {
      "alloc": {},
      "nonce": "0x0000000000000042",
      "difficulty": "0x020000",
      "mixHash": "0x000...000",
      "coinbase": "0x000...000",
      "timestamp": "0x00",
      "parentHash": "0x000...000",
      "extraData": "0x11bbe8db...",
      "gasLimit": "0x4c4b40"
    }
  5. Initialize Genesis Node

    geth --datadir data init genesis.json
  6. Start Genesis Node

    geth --datadir data --mine --etherbase 0 --minerthreads 2 --port 30303 --rpc --rpcapi "db,eth,net,web3,personal" --rpcaddr 10.37.129.2 --rpccorsdomain "*" console
  7. Verify Node Status

    • Check accounts: eth.accounts.
    • Query balance: eth.getBalance("0xfc...").

Step 2: Deploy Slave Nodes (Block Synchronization)

  1. Copy genesis.json to slave nodes and initialize:

    geth --datadir data init genesis.json
  2. Start Slave Node:

    geth --datadir data console
  3. Create Account (Similar to master node).
  4. Add Peer Connection to master node:

    admin.addPeer("enode://[email protected]:30303");
  5. Start Mining on both nodes:

    miner.start(2);  // Begin mining
    miner.stop();    // Stop mining

Automation Script

Create geth.sh to automate node startup:

geth --datadir /data/Ethereum/data --port 30303 --bootnodes "enode://[email protected]:30303" --mine --minerthreads 2 --nat "extip:10.51.110.21" --rpc --rpcapi "db,eth,net,web3,personal" --rpcaddr 10.51.110.21 --rpccorsdomain "*" console

Test RPC Call:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xabc...","latest"],"id":1}' 10.51.110.21:8545

FAQs

Q1: Why use a private chain over a public one?

A1: Private chains offer controlled access, higher privacy, and customizable consensus rules, ideal for enterprise or government use cases.

Q2: How do I resolve sync issues between nodes?

A2: Ensure:

Q3: Can I deploy nodes on cloud servers?

A3: Yes! 👉 Learn how to optimize cloud-based Ethereum nodes for scalability.

Q4: What’s the role of difficulty in genesis.json?

A4: It adjusts mining complexity—lower values speed up block creation but may cause forks.


Key Takeaways

By following this guide, you’ve built a fully functional Ethereum private chain—ready for custom applications!