$ 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 or hyphens, please) > helloworldprivate
Sweet, you can set this via --network=helloworldprivate next time!
INFO [04-10|13:45:58] Administering Ethereum network name=helloworldprivate WARN [04-10|13:45:58] No previous configurations found path=/Users/xiaoxuez/.puppeth/helloworldprivate
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) #共识选择,可直接选择pow,这里我选择的是poa,(不消耗计算力, 可以用于私链测试开发) 1. Ethash - proof-of-work 2. Clique - proof-of-authority > 2
How many seconds should blocks take? (default = 15) #5s出一个块 > 5
Which accounts are allowed to seal? (mandatory at least one) #输入有签名权限的账户 > 0x1186c97871079e86e9adcf11f56b90caa3619ea4 > 0x34c72adc7499cce01530dc27e67810a79fdbd8ea > 0xb37fe8ba7afbeb5e57139e55e737a34574e91a74 > 0x
Which accounts should be pre-funded? (advisable at least one) #输入有预留余额的账户 > 0xb37fe8ba7afbeb5e57139e55e737a34574e91a74 > 0x34c72adc7499cce01530dc27e67810a79fdbd8ea > 0x1186c97871079e86e9adcf11f56b90caa3619ea4 > 0x
Specify your chain/network ID if you want an explicit one (default = random) #输入私链ID, 直接输入回车,已默认随机数作为私链ID > INFO [04-10|13:47:49] 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
Which file to save the genesis into? (default = helloworldprivate.json) > INFO [04-10|13:48:00] 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 $ ls #结束后会在当前文件夹下看到导出的.json文件 helloworldprivate.json node1 node2 node3
接下来就是使用.json文件生成创世块了
1 2 3 4 5 6 7 8 9 10 11 12 13
#init:Bootstrap and initialize a new genesis block $ geth --datadir node1 init helloworldprivate.json $ geth --datadir node1 --port 30000 --nodiscover --unlock '0' --password ./node1/password console #启动geth, --port: Network listening port ,指定和其他节点链接所用的端口号 # --nodiscover: Disables the peer discovery mechanism (manual peer addition)关闭节点发现机制,防止加入有同样初始配置的陌生节点,后续手动配置节点网络, # --unlock: Comma separated list of accounts to unlock, 解锁的账户,以逗号分隔,账户要转帐或者部署合约,需要先解锁 # console: 进入控制台,不加console的话,也可在geth启动后通过geth attach ipc:node0/geth.ipc来访问 # --rpc: 表示开启http-rpc服务 --rpcport: 指定http-rpc服务监听端口,默认为8545 --ws: --wsport: --allow-insecure-unlock
> miner.start() INFO [04-10|17:59:10] Transaction pool price threshold updated price=18000000000 INFO [04-10|17:59:10] Starting mining operation null > INFO [04-10|17:59:10] Commit new mining work number=1 txs=2 uncles=0 elapsed=1.058ms INFO [04-10|17:59:10] Successfully sealed new block number=1 hash=3b7e10…38d85e INFO [04-10|17:59:10] 🔨 mined potential block number=1 hash=3b7e10…38d85e INFO [04-10|17:59:10] Commit new mining work number=2 txs=0 uncles=0 elapsed=285.156µs INFO [04-10|17:59:15] Successfully sealed new block number=2 hash=1bb861…fbcb78