【区块链学习】(2)以太坊私链搭建

1、GO语言安装

官网下载:https://golang.org/dl/

mac brew 安装

brew install go 

配置GO环境

vim .bash_profile //添加以下配置

GOROOT=/usr/local/Cellar/go/1.10.3/libexec //根据自身情况修改目录
GOPATH=/Users/XXXX/golang
GOBIN=$GOPATH/bin

source .bash_profile //配置生效
2、以太坊服务单节点搭建

创建创世块文件

vim genesis.json

添加以下信息

{
"config": {
        "chainId": 123456,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
},
"nonce": "0x0000000000000042",
"difficulty": "0x020000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x4c4b40",
"alloc": {}
}

初始化创世块,当前目录下会创建一个data目录

geth --datadir data init genesis.json

启动节点,并进入console交互模式

geth --datadir data --identity node1 --networkid 1 --rpc console

–Identity : 节点标识

–datadir : 节点数据存在位置,“data”

–rpc : 启用http-rpc服务器

–rpcapi : 基于http-rpc提供的api接口。eth,net,web3,db…

–rpcaddr : http-rpc服务器接口地址:默认“127.0.0.1”

–rpcport : http-rpc 端口(多节点时,不要重复)

–port : 节点端口号(多节点时,不要重复)

–networkid : 网络标识符 随便指定一个id(确保多节点是统一网络,保持一致)

猜你喜欢

转载自blog.csdn.net/GeekSnow/article/details/82255474