基于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

相关文章
相关标签/搜索