基于ethereum的五种链环境搭建方式 第6章 配置创世区块

还有没有比特币?你也太OUT了
注册OKEx交易所 快速购买比特币  

本章节主要介绍如何根据要求进行自定义创世区块以及如何使用puppeth命令。

1. 创建pubchain创世区块配置

1.1 执行puppeth命令

调用puppeth命令进行配置命令窗口

> puppeth --network pubchain

参数--network用于定义链名称。当然,也可以直接调用puppeth而不添加此参数。

1.2 选择[配置创世区块]选项
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
1.3 选择共识
Which consensus engine to use? (default = clique)
 1. Ethash - proof-of-work (pow)
 2. Clique - proof-of-authority (POA)[⬅︎选择此项]

大家可以根据自己需求,自由选择共识。本教程都是使用POA共识配置的,其实使用哪种共识在链部署步骤上都是相仿的。
另外,需要说明的是:POA是没有挖矿奖励的。

1.4 设置出块时间
How many seconds should blocks take? (default = 15)
> 15

此配置定义区块生产周期,即使没有交易也是会出块的。如果是本地开发环境,推荐设置为0,这样只有产生交易时才会出块。

1.5 设置挖矿帐户(至少一个)
Which accounts are allowed to seal? (mandatory at least one)
> 0x8e1d6472f156bc7d516f54594c536c5ba69f078f
> 0x

在POA中此帐户并不能通过挖矿来获取收益,只不过是拥有打包权而已。

1.6 设置预置资金账号
Which accounts should be pre-funded? (advisable at least one)
> 0xdf3f8d80c55d252ca5a12d3bed4e6d54a3f23a7c
> 0x

此配置主要是用于初始化链数据的时候给指定帐户预置一些金额。

1.7 设置链id,供后续rpc服务调用
Specify your chain/network ID if you want an explicit one (default = random)
> 100

链ID。当多节点进行集群部署时,用于区分是不是同一条链。

1.8 导出配置
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
Which file to save the genesis into? (default = pubchain.json)
> ⏎ (注: 回车,即可导出当前创世区块配置至当前目录.)

2. 查看当前配置

> ls -al
pubchain.json
> cat pubchain.json
{
  "config": {
    "chainId": 100,
    "homesteadBlock": 1,
    "eip150Block": 2,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 3,
    "eip158Block": 3,
    "byzantiumBlock": 4,
    "clique": {
      "period": 15,
      "epoch": 30000
    }
  },
  "nonce": "0x0",
  "timestamp": "0x5bd2a79a",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000453459f5540fd6916998791a81546a9f3270b0cb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x47b760",
  "difficulty": "0x1",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
    "e38235e6b8c2fccb0b6cb1689bb80996a393e94b": {
      "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
    }
  },
  "number": "0x0",
  "gasUsed": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

 

本文由 区块链技术网 作者:区块链 发表,其版权均为 区块链技术网 所有,文章内容系作者个人观点,不代表 区块链技术网 对观点赞同或支持。如需转载,请注明文章来源。

还有没有比特币?你也太OUT了
注册OKEx交易所 快速购买比特币  

发表评论