DApp Local Environment Deployment Guide

ยท

Introduction

This comprehensive guide walks you through deploying decentralized applications (dApps) on a private blockchain test environment using pre-built smart contracts and frontend applications.

Prerequisites

GO Environment Setup

  1. Installation:

    • Download from Golang official website

      wget https://golang.org/dl/go1.15.7.linux-amd64.tar.gz
      tar -C /usr/local -xzf go1.15.7.linux-amd64.tar.gz
      echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
    • Note: Versions below GO 1.13 cannot compile go-ethereum from source.

Geth Installation

  1. Build from Source:

    git clone https://github.com/ethereum/go-ethereum.git
    cd go-ethereum
    make geth
    echo 'export PATH=$PATH:/build/bin' >> ~/.bashrc

Blockchain Initialization

Genesis Configuration

Use puppeth to create a custom genesis file (required only for the first node):

mkdir -p ChainSkills/private
cd ChainSkills/private
puppeth

Follow the interactive prompts to:

Initialize the blockchain:

geth --datadir . init cfca.json

Account Management

Creating Accounts

Each node can independently create accounts:

geth --datadir . account new

Follow prompts to set passwords and generate keys. Repeat for multiple accounts.

Listing Accounts

View created accounts:

geth --datadir . account list

Node Deployment

Launching the First Node

geth --networkid 6996 --mine --miner.threads 1 --datadir . --nodiscover \
     --http --http.addr 192.168.32.69 --http.port 8545 --port 30301 \
     --http.corsdomain "*" --http.api eth,web3,net,personal \
     --ipcpath ~/.ethereum/geth.ipc

Adding Peer Nodes

  1. Initialize New Node:

    mkdir local && cd local
    geth --datadir . init cfca.json
  2. Start Clef Signer:

    clef --keystore ./keystore/ --http --chainid 6996
  3. Connect to Bootstrap Node:

    geth --datadir . --bootnodes="enode://<node-id>@192.168.32.69:30301" \
         --networkid 6996 --port 30301 --http --http.port 8545 --mine \
         --miner.threads 1 --signer http://127.0.0.1:8550

DApp Deployment

Source Code Setup

git clone https://github.com/dappuniversity/eth_swap.git
cd eth_swap
npm install
truffle migrate
npm run start

Using the DApp

MetaMask Configuration

  1. Install the MetaMask browser extension
  2. Import accounts:

    • Method 1: Use Geth-created accounts via keystore files
    • Method 2: Create new accounts directly in MetaMask

๐Ÿ‘‰ Learn advanced blockchain deployment techniques

Account Funding

FAQ Section

Q1: Why use a private blockchain for dApp testing?

A: Private blockchains allow controlled environments without real cryptocurrency costs, ideal for development and debugging.

Q2: How do I resolve "Insufficient GO version" errors?

A: Ensure you're using GO 1.13+. Check version with go version and upgrade if necessary.

Q3: What's the purpose of Clef?

A: Clef manages account keys and transaction signing separately from Geth, enhancing security.

Q4: How long does account import take?

A: Typically 5-6 minutes. If MetaMask stalls, click "Wait" to continue.

๐Ÿ‘‰ Explore more Ethereum development tools

Troubleshooting

This guide provides complete coverage for setting up a local dApp environment, from infrastructure to application deployment. For production environments, consider additional security measures and network monitoring tools.