简介
这里以太坊的一些特性就不赘述,可以在官网进行查阅:https://www.ethereum.org/。
下面主要介绍基于POA机制的环境的搭建来窥探以太坊的运行机制。
源码下载及编译
1、git clone https://github.com/ethereum/go-ethereum
2、git checkout -b remotes/origin/release/1.8这里采用1.8这个分支
3、make all 进行编译,会产生一些可执行文件。
创建节点目录
这里我们创建node1,node2,node3,node4节点目录,这里假设node3,node4为挖矿节点
创建账户
1、./geth --datadir node1/data account new
2、./geth --datadir node2/data account new
3、./geth --datadir node3/data account new
4、./geth --datadir node4/data account new
其中各节点账户为:
node1:UTC--2019-06-05T02-30-12.367011247Z--def0ad9fc2fb1633b0c64587e42e3c5201264187
node2:UTC--2019-06-05T02-30-35.034825952Z--3ceafa56c08c0353b062beec0646a3e2234c5df1
node3:UTC--2019-06-05T02-31-12.018584833Z--23e46dc2a103314cc3ee8085734bf17ebc18249e
node4:UTC--2019-06-05T02-31-20.086986887Z--5e390a88062c4f8eff2686cdef5b4c5abe7d7f7e
生成创世块文件
利用编译生成的客户端交互工具puppeth可以生成创世块文件。
直接运行./puppeth按照提示选择即可,最后生成poa_test.json文件。
需要注意的是:
1、指定networkid这里指定为666,否则随机生成
2、输入指定的挖矿账户,这里我们把node3的账户(23e46dc2a103314cc3ee8085734bf17ebc18249e)上去即可。
3、指定初始化账户余额,这里指定node1,node3账户,下面会介绍转账的操作。
初始化私有链
1、./geth --datadir node1/data init poa_test.json
2、./geth --datadir node2/data init poa_test.json
3、./geth --datadir node3/data init poa_test.json
4、./geth --datadir node4/data init poa_test.json
启动节点
./geth --datadir node1/data --networkid 666 --port 3000 console
./ge