current position:Home>Experience - deploy Ethereum private chain (POA)

Experience - deploy Ethereum private chain (POA)

2022-02-03 05:28:13 Brick moving leader

Deploy a set of Ethereum private chain locally , Use... For the alliance chain PoA Consensus
If you use the default PoW Consensus , Look at this article : Experience - Deploy Ethereum private chain (PoW)


stay poa Create three folders under the directory , Namely bootdir,node1,node2 Three folders .

mkdir poa
cd poa
mkdir bootdir node1 node2

stay bootdir Create in folder bootnode Nodes are used to do p2p Network routing .

./bootnode --genkey boot.key # Create a boot.key Of key file .
./bootnode --nodekey boot.key # start-up bootnode Routing node .

# The echo message is as follows ,  After the start node You'll use 
UDP listener up                          self=enode://bde0739c7d9f213054575574d6e8e1df21147066a666bc939f29634dac947ad5c[email protected][::]:30301

# perhaps   Background operation 
nohup bootnode -nodekey boot.key -verbosity 9 -addr :30301 2>> bootnode_output.log &

(2) Create an account

stay node1 node2 Create an account under the directory ( password 123456)

./geth account new

(3) Generate Genesis documents

Use puppeth To produce the creation document . puppeth yes geth The program that comes with it , You can guide users to create geth The document of creation .
function puppeth stay poa Directory generation genesis.json file


# Then you need to interact 
| Welcome to puppeth, your Ethereum private network manager |
|                                                           |
| This tool lets you create a new Ethereum network down to  |
| the genesis block, bootnodes, miners and ethstats servers |
| without the hassle that it would normally entail.         |
|                                                           |
| Puppeth uses SSH to dial in to remote servers, and builds |
| its network components out of Docker containers using the |
| docker-compose toolset.                                   |
Please specify a network name to administer (no spaces or hyphens, please)
> poa
Sweet, you can set this via --network=poa next time!
INFO [06-23|17:10:34] Administering Ethereum network           name=poa
INFO [06-23|17:10:34] No remote machines to gather stats from 
What would you like to do? (default = stats)
 1. Show network stats
 2. Configure new genesis
 3. Track new remote server
 4. Deploy network components
> 2
Which consensus engine to use? (default = clique)
 1. Ethash - proof-of-work
 2. Clique - proof-of-authority
> 2
How many seconds should blocks take? (default = 15)
> 2
Which accounts are allowed to seal? (mandatory at least one)
> 0xd71ad920f80e6a1e06689a720f24b335f22d557e
> 0x8bbc43acd355be0cecc61872e13e0a0e53c700b7
> 0x
Which accounts should be pre-funded? (advisable at least one)
> 0x0xd71ad920f80e6a1e06689a720f24b335f22d557e
ERROR[06-23|17:11:33] Invalid address length, please retry 
> 0xd71ad920f80e6a1e06689a720f24b335f22d557e
> 0x
Specify your chain/network ID if you want an explicit one (default = random)
> 1500
INFO [06-23|17:12:05] Configured new genesis block 
What would you like to do? (default = stats)
 1. Show network stats
 2. Manage existing genesis
 3. Track new remote server
 4. Deploy network components
> 2
 1. Modify existing fork rules
 2. Export genesis configuration
 3. Remove genesis configuration
> 2
Which file to save the genesis into? (default = poa.json)
> genesis.json
INFO [06-23|17:12:27] Exported existing genesis block 
What would you like to do? (default = stats)
 1. Show network stats
 2. Manage existing genesis
 3. Track new remote server
 4. Deploy network components

> ^C

(4) Initialize and start the node

# Init node1 & node2
echo "Init node1 & node2."
geth --datadir node1 init genesis.json
geth --datadir node2 init genesis.json

sleep 1s

# Startup node1
echo "Startup node1."
nohup geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr --rpcport 8501 \
--rpcapi 'personal,db,eth,net,web3,txpool,miner' --rpccorsdomain "*" --ws --wsaddr --wsport 8601 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" \
--bootnodes 'enode://bde0739c7d9f213054575574d6e8e1df21147066a666bc939f29634dac947ad5c[email protected]' \
--networkid 1515 --gasprice '1' -unlock '0xbac5564cc4f7528ebb6150270ee63b3fa1641b17' --password node1/password.txt --mine \
2>>node1/eth_output.log &

sleep 1s

# Startup node2
echo "Startup node2."
nohup geth --datadir node2/ --syncmode 'full' --port 30312 --rpc --rpcaddr 'localhost' --rpcport 8502 \
 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --ws --wsaddr --wsport 8602 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" \
 --bootnodes 'enode://bde0739c7d9f213054575574d6e8e1df21147066a666bc939f29634dac947ad5c[email protected]' \
 --networkid 1515 --gasprice '1' -unlock '0x8a6673dc85e544bce6d4876f63cfcdc4e5c8cc08' --password node2/password.txt --mine \
 2>>node2/eth_output.log &

# Jobs command
# jobs
# kill %1
# kill %2
# kill %3

Record on pit

(1) When starting node mining , Need to wear a sign –syncmode “full”, Otherwise, report errors :
Clique : Discarded bad propagated block #1 when syncing

(2) When starting node mining , You need to bring it with you at startup --unlock “ account number ”, Otherwise, mining failure will be reported after mining for a certain time , Error that needs to be unlocked .

Reference resources


Past highlights :
Blockchain Knowledge Series
Cryptography series
Zero knowledge proof series
Consensus series
Public chain series
Bitcoin series
Ethereum series
EOS series
Filecoin series
Alliance chain series
Fabric series
Smart contract series
Token series

copyright notice
author[Brick moving leader],Please bring the original link to reprint, thank you.

Random recommended