基於PoA的以太坊私鏈搭建過程

1、搭建環境

     宿主系統:Windows 10 家庭版前端

      虛擬機:   Virtual Box  6.0.12node

      操做系統:CentOS 7 64 位linux

2、安裝基礎工具


下載並安裝Git、vim、gcc-c++、ntp組件、nodejs以及添加epel第三方安裝源。這些工具的說明以下:c++

git:安裝相關的組件,下載安裝各種開源代碼與工具的利器;
gcc-c++:c/c++編譯工具,用於golang下部分c庫的編譯以及truffle組件的編譯
ntp:網絡時鐘同步組件;Ethereum的rpc網絡須要時間同步;
nodejs:ethereum前端開發JavaScript包管理軟件
epel:網絡第三方的linux安裝包源git

3、安裝cmake

echo "export PATH=/usr/local/cmake-3.15.7/bin:$PATH" >> /etc/profile
source /etc/profile
cmake -version

4、安裝Golang

注意:安裝包地址可能有變動,可到官網上找github

wget https://storage.googleapis.com/golang/go1.14.linux-amd64.tar.gz
tar -C /usr/local -zxzf go1.14.linux-amd64.tar.gz
echo "export GOROOT=/usr/local/go" >> /etc/profile
echo "export PATH=/usr/local/go/bin:$PATH" >> /etc/profile
source /etc/profile

5、 編譯並安裝 go-ethereum

cd /usr/local
git clone https://github.com/ethereum/go-ethereum.git  
cd go-ethereum/
make all
echo "export PATH=$PATH:/usr/local/go-ethereum/build/bin" >> /etc/profile
source /etc/profile

6、創新私有鏈

能夠參考官方提供的方式: https://github.com/ethereum/go-ethereumgolang

一、建立帳號

geth --datadir node account new

  建立多個帳號,並記錄保存帳號地址和密碼docker

二、生成創世塊json

[root@karlwang mygeth]# puppeth
+-----------------------------------------------------------+
| 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, hyphens or capital letters please)
> deling

Sweet, you can set this via --network=deling next time!

INFO [03-01|15:35:52.308] Administering Ethereum network           name=deling
WARN [03-01|15:35:52.308] No previous configurations found         path=/root/.puppeth/deling

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

What would you like to do? (default = create)
 1. Create new genesis from scratch
 2. Import already existing genesis
> 1

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)
> 

Which accounts are allowed to seal? (mandatory at least one)
> 0x047f1Efd0097181aB214BeeBB7F43a16b5A92a59
> 0x55b30a8Be73B7420b529A2E5D912D0Fe73904409
> 0xF2378906ff0c45489B1D1FcC23e1Fd1b623473A8
> 0x

Which accounts should be pre-funded? (advisable at least one)
> 0x047f1Efd0097181aB214BeeBB7F43a16b5A92a59
> 0x55b30a8Be73B7420b529A2E5D912D0Fe73904409
> 0xF2378906ff0c45489B1D1FcC23e1Fd1b623473A8
> 0x

Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes)
> yes

Specify your chain/network ID if you want an explicit one (default = random)
> 2020
INFO [03-01|15:38:46.011] 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 configurations
 2. Export genesis configurations
 3. Remove genesis configuration
> 2

Which folder to save the genesis specs into? (default = current)
  Will create deling.json, deling-aleth.json, deling-harmony.json, deling-parity.json
> 
INFO [03-01|15:39:31.083] Saved native genesis chain spec          path=deling.json
ERROR[03-01|15:39:31.083] Failed to create Aleth chain spec        err="unsupported consensus engine"
ERROR[03-01|15:39:31.083] Failed to create Parity chain spec       err="unsupported consensus engine"
INFO [03-01|15:39:31.086] Saved genesis chain spec                 client=harmony path=deling-harmony.json

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
> 1
INFO [03-01|15:41:02.182] No remote machines to gather stats from 

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

這個私有鏈搭建完成,可使用錢包進行鏈接vim

7、安裝以太坊客戶端ganache鏈接節點

請參考: https://www.trufflesuite.com/ganache

固然也能夠用錢包鏈接,鏈接節點

 

參考資料:

CentOS7下安裝Geth,搭建以太坊私有鏈

https://blog.csdn.net/kevinyankai/article/details/99574196

 

以太坊私鏈教程:如何搭建基於PoA的以太坊私鏈(聯盟鏈)

https://www.jianshu.com/p/c16fe39b8548

相關文章
相關標籤/搜索