(2) 基于以太坊智能合约的Dapp开发与实践 - 定制创世区块

1, 定制创世区块

1.1 创建工作目录

创建工作目录“devnet”,创建两个节点目录

$mkdir devnet
$cd devnet
$mkdir node1 ndoe2

1.2 生成账户

初始化两个节点的以太坊账户与密码

$geth --datadir node1/ account new
$geth --datadir node2/ account new
$echo {ACCOUNT1} >> accounts.txt
$echo {ACCOUNT2} >> accounts.txt
$echo {PASSWD1} > node1/password.txt
$echo {PASSWD2} > node2/password.txt

1.3 创建创世区块

使用以太坊自带工具puppeth生成创世区块

$puppeth
Please specify a network name to administer (no spaces, please)

> devnet

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

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)

> 3 // for example

Which accounts are allowed to seal? (mandatory at least one)

> 0x87366ef81db496edd0ea2055ca605e8686eec1e6 //copy paste from account.txt :)

> 0x08a58f09194e403d02a1928a7bf78646cfc260b0

Which accounts should be pre-funded? (advisable at least one)

> {ACCOUNT1} // free ethers !

> {ACCOUNT2}

Specify your chain/network ID if you want an explicit one (default = random)

> {NETWORK_ID} // for example. Do not use anything from 1 to 10

Anything fun to embed into the genesis block? (max 32 bytes)

>

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

> 2

Which file to save the genesis into? (default = devnet.json)

> genesis.json

INFO [01-23|15:16:17] Exported existing 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

> ^C // ctrl+C to quit puppeth

生成了genesis.json到当前路径

你可能感兴趣的:((2) 基于以太坊智能合约的Dapp开发与实践 - 定制创世区块)