Windows下搭建以太坊私有链环境1.8.2

1、下载Geth.exe 运行文件,并安装

访问不了可以访问国内镜像地址下载

下载 geth-windows-amd64-1.8.2后安装
2、cmd进入安装目录运行:geth -help看看是否可用geth命令
3、在Geth安装目录下放置初始化创世块文件genesis.json
{
  "nonce":"0x0000000000000042",
  "mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",
  "difficulty": "0x4000",
  "alloc": {},
  "coinbase":"0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "
0x00000000 ",
  "gasLimit":"0xffffffff",
  "config": {
    "chainId": 666,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  }
}
注意红色部分:

不然会出现错误“Fatal: invalid genesis file: json: cannot unmarshal hex string without 0x prefix into Go struct field Genesis.extraData of type hexutil.Bytes

解释:


4、cmd进入geth安装目录,初始化创世块 cmd输入geth --datadir "%cd%\chain" init genesis.json
%cd%:代表Geth安装目录
5、创建私有链 打开geth控制台  geth -datadir "%cd%\chain"  --nodiscover console 2
6、在私有链上创建账号,键入:personal.newAccount()
会提示输入密码,我输入:123456

7、挖矿
开始挖矿miner.start()
结束挖矿miner.stop()
8、命令查看主账户中以太币的数量
eth.getBalance(eth.accounts[0]) 结果不为0,说明挖矿成功
9、 图形化钱包查看账户以太币数量
下载打开图形化钱包 https://github.com/ethereum/mist/releases/
访问不了可以访问 国内镜像地址下载 
当前下载版本为 Windows 系统: Ethereum-Wallet-installer-0-9-3.exe
安装之后运行这个钱包,运行Ethereum-Wallet.exe,即启动成功,如果区块链正常的话,会在右上角显示“PRIVATE-NET”,点击“LAUNCH APPLICATION”进入图形界面即可查看,如下图:


猜你喜欢

转载自blog.csdn.net/lipei1220/article/details/79475283