30分钟部署以太坊私有链
以windows为例,大约30分钟可部署好一个以太坊测试网络。
准备工作:
1、下载Geth v1.6.7:
https://github.com/ethereum/go-ethereum/releases/
2、下载Mist 0.8.10:
https://github.com/ethereum/mist/releases/
第一步:
安装Geth,我直接装到了C:/Geth/下,路径短方便,避免中文路径。
安装Mist,路径随意,我直接C盘默认路径。
第二步:
手动创建创世区块,在C:/Geth/下新建文件Genesis.json,用记事本编辑保存如下内容:
{
"nonce":"0x0000000000000042",
"mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x1000",
"alloc": {},
"coinbase":"0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit":"0xffffffff",
"config": {
"chainId": 111,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
}
}
第三步:
对创世区块进行初始化,运行cmd,进入C:/Geth/目录后,输入:
geth -datadir "%cd%chain" init genesis.json
初始化完成后,进入Geth控制台:
geth -datadir "%cd%chain" console
在控制台里新建一个以太坊主账户:
personal.newAccount("password1")
然后退出控制台
exit
启动私有链节点:
geth -targetgaslimit 4294967295 -rpc -rpcaddr "127.0.0.1" -rpcport "8101" -port "30301" -rpcapi "eth,web3,personal" -networkid 123 -identity 123 -nodiscover -maxpeers 5 -datadir "%cd%chain" -unlock 0 -rpccorsdomain "*" -mine console
输入账户密码:
password1
如果一切正常,那么主账户现在应该开始挖矿了。
注意,如果提示30301端口异常的话,很有可能是因为已经运行了Mist,关掉Mist应该就好了。
第四步:
打开Mist,欢迎界面中右上角会出现Private-net,点击下方Launch application进入Mist。成功进入后可以看到主账户,余额不断增加,因为在不断的挖矿。
注意,如果进入Mist后,在Private-net状态下无法进入主账户,说明Mist没有连接到私有链节点。一定是第三步哪里没有做对。回头重做。
至此,一个以太坊私有链搭建完毕。
- 上一篇:没有了
- 下一篇:没有了