How to Set Up an Ethereum Private Chain with PoA Consensus (Part 2)

·

In this chapter, we'll cover initializing your private Ethereum blockchain, creating the genesis block, running nodes, recording transactions, and mining.


Initializing the Genesis Block

To initialize the genesis block, use the following command:

geth --datadir node1 init node.json

This reveals critical information such as:


Launching the Node with Custom Parameters

Before starting the node, configure it using go-ethereum's command-line options. Execute:

geth --datadir node1 --allow-insecure-unlock --nodiscover --syncmode "full" --networkid 7777 --port 30303 --rpc --rpcport 8545 --rpcapi "eth,net,web3" --unlock "f96f9d02cb76cf745d5bd37bd040ac203926f600" --password /Users/wusonglin/node1/password.txt console

Key Parameters Explained:

After execution, the console displays the node’s coinbase address, module status, and data directory.


Sending and Validating Transactions

Step 1: Submit a Test Transaction

eth.sendTransaction({
  from: eth.accounts[0],
  to: "0x91449c31b4f1b6651Acd4bAe4A2067C009750392",
  value: web3.toWei(100000, "ether")
});

Step 2: Check Transaction Status

With no active miners, transactions remain in the pending pool. Verify with:

txpool.inspect.pending

Step 3: Start Mining

miner.start()

Recheck the pool to confirm the transaction is processed:

txpool.inspect.pending  // Returns empty if successful

FAQ Section

Q1: Why use --allow-insecure-unlock?

This bypasses HTTP unlocking security for local testing. Never use in production.

Q2: What’s the difference between full and fast sync?

Full validates all historical blocks; fast skips validation for quicker synchronization.

Q3: How do I change the default RPC port?

Modify --rpcport (e.g., --rpcport 9000).

👉 Explore advanced Ethereum development tools for more insights.

Q4: Can I mine without transactions?

Yes, but empty blocks waste resources. Always queue transactions first.

👉 Learn about PoA consensus mechanisms to optimize your private chain.


Key Takeaways

For further reading, see our guide on PoA consensus best practices.