码迷,mamicode.com
首页 > 其他好文 > 详细

区块链:以太坊基础之搭建私链

时间:2020-01-05 20:51:20      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:ant   col   top   挖矿   number   miner   peter   提示   home   

1.新建genesis.json

{
  "config": {
    "chainId": 666,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "ethash": {}
  },
  "nonce": "0x0",
  "timestamp": "0x5ddf8f3e",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x47b760",
  "difficulty": "0x00002",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
    "0x1e82968C4624880FD1E8e818421841E6DB8D1Fa4" : {"balance" : "30000000000000000000"}
  },
  "number": "0x0",
  "gasUsed": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

各个参数的解释可参考:https://www.cnblogs.com/wanghui-garcia/p/10256520.html

 

如果没有alloc后面的部分,可能出现:Fatal: Failed to write genesis block: unsupported fork ordering: eip150Block not enabled, but eip155Block enabled at 0 错误

具体参考:http://www.blogjava.net/waterjava/archive/2019/11/28/434937.html

2.启动

2.1.初始化

geth --datadir /usr/geth/data init /usr/geth/config/genesis.json

2.2.启动私链并进入控制台

geth --datadir /usr/geth/data --networkid 666 console

3.创建账户挖矿

3.1.创建账户

personal.newAccount()  然后根据提示输入密码

personal.newAccount("123456")  创建账户的同时指定密码

3.2.挖矿

miner.start(1)  括号里不填的话是默认全力挖矿

3.3.停止

miner.stop()  停止挖矿

区块链:以太坊基础之搭建私链

标签:ant   col   top   挖矿   number   miner   peter   提示   home   

原文地址:https://www.cnblogs.com/fdzang/p/12152569.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!