current position:Home>Experience part - deploying Ethereum private chain (POW)

Experience part - deploying Ethereum private chain (POW)

2022-02-03 05:29:34 Brick moving leader

Deploy a set of Ethereum private chain locally , Use the default first PoW Consensus

#!/bin/bash

# Clear node1 & node2
echo "Clear node1 & node2 & node3."
rm -rf node1/geth
rm -rf node2/geth
rm -rf node3/geth
rm -rf node1/eth_output.log
rm -rf node2/eth_output.log
rm -rf node3/eth_output.log
rm -rf bootnode_output.log

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

# Startup bootnode
# echo "Startup bootnode."
nohup bootnode -nodekey boot.key -verbosity 9 -addr :30301 2>> bootnode_output.log &
sleep 1s

# Startup node1
echo "Startup node1."
nohup geth --datadir=node1 \
--bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf71[email protected]127.0.0.1:30301 \
--networkid 2525 --port=30303 --rpc --rpcaddr 0.0.0.0 --rpcport=8545 --rpcapi 'personal,db,eth,net,web3,txpool,miner' \
--ws --wsaddr 0.0.0.0 --wsport 8546 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" \
 2>>node1/eth_output.log &

sleep 1s

# Startup node2
echo "Startup node2."
nohup geth --datadir=node2 \
--bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf71[email protected]127.0.0.1:30301 \
--networkid 2525 --port=30304 --rpc --rpcaddr 0.0.0.0 --rpcport=8645 --rpcapi 'personal,db,eth,net,web3,txpool,miner' \
--ws --wsaddr 0.0.0.0 --wsport 8646 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" \
 2>>node2/eth_output.log &

sleep 1s

# Startup node3
echo "Startup node3."
nohup geth --datadir=node3 \
--bootnodes=enode://2cb6fe8f4a73fdc962bae49cfcc131e642a9f3b9d6cff1384d5e14ad7d25ebf71[email protected]127.0.0.1:30301 \
--networkid 2525 --port=30305 --rpc --rpcaddr 0.0.0.0 --rpcport=8745 --rpcapi 'personal,db,eth,net,web3,txpool,miner' \
--ws --wsaddr 0.0.0.0 --wsport 8746 --wsapi 'personal,db,eth,net,web3,txpool,miner' --wsorigins "*" \
--mine --minerthreads=1 --etherbase="0x3ca39a64bc1eda8669d539631b44dbd4a43ed0f8" \
-unlock '0x3ca39a64bc1eda8669d539631b44dbd4a43ed0f8' --password node3/password.txt \
2>>node3/eth_output.log &

# Jobs command
# jobs
# kill %1 for bootnode
# kill %2 for geth of node1
# kill %3 for geth of node2
# kill %4 for geth of node3

Reference resources

  • http://www.cnblogs.com/xd502djj/p/3612131.html
  • https://blog.csdn.net/fengyifei11228/article/details/5737371
  • http://www.cnblogs.com/mfryf/archive/2012/05/09/2491322.html

Past highlights :
Blockchain Knowledge Series
Cryptography series
Zero knowledge proof series
Consensus series
Public chain research series
Bitcoin series
Ethereum series
EOS 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.
https://en.netfreeman.com/2022/02/202202030529331529.html

Random recommended