没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
以太坊 geth 私链安装配置详细步骤
编程老兵
近期在学习以太坊相关的知识,发现网上的内容由于版本和其它原因,很
多都是有问题的,到处都是坑,我根据自己的实践总结了本文,希望给相关的
同学一些帮助和指导,避免一些坑!
为了避免混淆和误会,本文相关的环境和版本如下:
1) 主机:Windows10 64 位专业版
2) 虚拟机 1: Ubuntu16.04 64 位,主机名 s1
3) 虚拟机 2: Ubuntu16.04 64 位,主机名 s2
4) geth 版本:1.8.12-stable-37685930
5) nodejs 版本:v8.11.3
1. geth 安装配置
安装可以参考官方文档:https://github.com/ethereum/go-
ethereum/wiki/Installation-Instructions-for-Ubuntu
安装步骤如下:
1) sudo apt-get install software-properties-common
2) sudo add-apt-repository -y ppa:ethereum/ethereum
3) sudo apt-get update
4) sudo apt-get install ethereum
5) 检查 geth 版本
2. 创建 geth 私链
2.1. 创世块文件
创建私链需要定义创世块文件,这个文件用来创建区块链的创世区块。本文创
世块文件 mygenesis.json 如下:
mygenesis.json
{
"config": {
"chainId": 168,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x2000",
"extraData" :
"0x54686973206973206d7920666972737420457468657265756d20426c6f636b6368
61696e21",
"gasLimit" : "0xffffffff",
"nonce" : "0x0000000000000042",
"mixhash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": { }
}
具体内容说明可以参考百度其它文章,本文不在赘叙。
2.2. 创建创世块
执行下面命令初始化创世块:
geth --datadir "./myblockchain" init mygenesis.json
屏幕输出:
t1@s1:~/ethereum$ cat mygenesis.json
{
"config": {
"chainId": 168,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x4000",
"extraData" :
"0x54686973206973206d7920666972737420457468657265756d20426c6f636b6368
61696e21",
"gasLimit" : "0xffffffff",
"nonce" : "0x0000000000000042",
"mixhash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": { }
}
t1@s1:~/ethereum$ geth --datadir "./myblockchain" init
mygenesis.json
WARN [07-26|19:06:57.512] Sanitizing cache to Go's GC limits
provided=1024 updated=664
INFO [07-26|19:06:57.548] Maximum peer count
ETH=25 LES=0 total=25
INFO [07-26|19:06:57.597] Allocated cache and file handles
剩余19页未读,继续阅读
资源评论
70编程老兵
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功