1. Ethereum Installation, Private Chain Genesis Block Setup, and Node Addition
1.1 Ethereum Installation
Official Download Link: Geth Ethereum
Download the appropriate Geth version for your OS. Verify installation by checking the version:
geth version 1.2 Private Chain Genesis Block Setup
Create
genesis.json:{ "config": { "chainId": 15, "homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0 }, "difficulty": "0x400", "gasLimit": "0x8000000", "alloc": {} }Initialize Genesis Block:
geth --datadir "./chain" init ./genesis.json--datadir: Specifies blockchain data storage location.Start Private Chain:
geth --datadir "./chain" --nodiscover console 2>> eth_output.log--nodiscover: Ensures the chain remains private.- Monitor logs:
tail -f eth_output.log(Windows users need Tail.exe). Account Management:
personal.newAccount("password") // Create account eth.accounts // List accounts web3.fromWei(eth.getBalance(eth.accounts[0]), "ether") // Check balanceMining:
miner.start(1) // Start mining miner.stop() // Stop mining
1.3 Adding Nodes to the Private Chain
Retrieve First Node’s
enodeURL:admin.nodeInfo.enodeInitialize Second Node:
geth --datadir "./chain2" init ./genesis.json geth --datadir "./chain2" --port 30305 --nodiscover consoleConnect Nodes:
admin.addPeer("enode://<first-node-id>@127.0.0.1:30303")Verify Connection:
net.peerCount // Should return 1
2. Explanation of getBlock Fields
| Field | Description |
|--------|-------------|
| difficulty | Block mining difficulty (adjusts dynamically). |
| extraData | Custom metadata or notes. |
| gasLimit | Max gas allowed per block. |
| hash | Block’s unique hash. |
| miner | Miner’s address (reward recipient). |
| nonce | Proof-of-Work hash. |
| transactions | List of transactions or hashes. |
👉 Explore Ethereum development tools
3. Log Output Interpretation
- Startup Logs: Configuration, protocol initialization, memory allocation.
Mining Logs:
Generating DAG: Directed Acyclic Graph creation for mining.Successfully sealed new block: New block confirmed.
- Transactions:
Submitted transactionindicates broadcasted TX.
4. Smart Contract Deployment
Write a Simple Contract (e.g., Solidity):
pragma solidity ^0.8.0; contract SimpleCalc { function f(uint a, uint b) public pure returns (uint) { return a * b; } }- Compile in Remix: Copy
WEB3DEPLOYcode. Deploy via Geth:
personal.unlockAccount(acc0, "password") miner.start(1) // Paste WEB3DEPLOY code- Success:
Contract mined!appears. Call Contract Function:
SimpleCalc.f(3, 8) // Returns 24
5. Transaction Field Breakdown
blockHash: Parent block’s hash.gasPrice: Gas cost per unit (wei).input: Data for contract calls/deployment.value: Transferred Ether (wei).
👉 Master Ethereum transactions
6. Quick Command Reference
| Command | Purpose |
|---------|---------|
| geth init | Initialize genesis block. |
| miner.start() | Begin mining. |
| eth.sendTransaction() | Send Ether. |
FAQ
Q1: How do I resolve ‘DAG generation’ delays?
A1: DAG generates once per epoch (~30,000 blocks). Pre-download it using geth makedag.
Q2: Why is my transaction pending?
A2: Ensure the sender’s account is unlocked and has sufficient gas.
Q3: How to secure a private chain?
A3: Use --nodiscover and restrict RPC access (--rpcapi).