1. 安装go环境
wget https://studygolang.com/dl/golang/go1.13.10.linux-amd64.tar.gz
tar -zxvf go1.13.10.linux-amd64.tar.gz
mkdir go-pck
#配置环境变量
export GOROOT=$HOME/my-app/go #go目录
export GOPATH=$HOME/my-app/go-pck #go依赖包目录
export PATH="$PATH:$GOROOT/bin"
#使用阿里云 Go Module 国内镜像仓库服务
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
2.安装go-ethereum
git clone git@gitee.com:mirrors/go-ethereum.git
cd go-ethereum
make geth
/**Ubuntu会出现以下错误,找到hid.c文件 将 include <iconv.h> 改为 include "/usr/include/iconv.h"
*../go-pck/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/hidapi/libusb/hid.c:444*:对‘libiconv_open’未定义的引用
*../go-pck/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/hidapi/libusb/hid.c:456:对‘libiconv’未定义的引用
*../go-pck/pkg/mod/github.com/karalabe/usb@v0.0.0-20190919080040-51dc0efba356/hidapi/libusb/hid.c:471:对‘libiconv_close’未定义的引用
**/
3. 搭建私链
mkdir my_private
cd my_private
touch genesis.json
#填入以下内容
{
"config": {
"chainId": 20
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0
},
"alloc": {},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x2000", #挖矿难道
"extraData": "",
"gasLimit": "0x2fefd8",
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
#初始化
geth init ./genesis.json
#启动私链
geth --datadir . --networkid 20 --rpc console 2 > output.log
4. 启动测试链
mkdir dev-eth
cd dev-eth
touch output.log
geth --datadir . --dev --rpc --rpcapi="eth,net,web3,personal" console 2>output.log
网友评论