由於最近雲小哥哥換了一份工做,新公司比較忙,因此一直沒有更新新的博客。雲小哥哥新的公司是作區塊鏈的,最近在學習區塊鏈相關的東西(也算是乘坐上了區塊鏈這艘大船)。本博客是記錄我搭建ethereum的debug環境的步驟。git
經過 brew 就能夠安裝上述提到的全部工具,其餘操做系統請自行安裝上述工具。github
1.查看go的環境,找到 GOPATH golang
command:json
go env
output:ide
GOARCH="amd64" GOBIN="" GOCACHE="/Users/qingyun.yu/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/qingyun.yu/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.10.3/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cg/xnlvmg894zs64pmk0cvzxxg1jzppgf/T/go-build103516383=/tmp/go-build -gno-record-gcc-switches -fno-common"
經過上面的輸出,咱們就能夠找到 GOPATH 的配置爲 /Users/qingyun.yu/go 工具
2.進入 /Users/qingyun.yu/go文件夾學習
command:區塊鏈
cd /Users/qingyun.yu/go
3.在文件夾上建立如下目錄ui
eth/ src/ github.com/ ethereum/ golang.org/ bin/ pkg/
command:spa
mkdir eth eth/bin eth/src eth/pkg eth/src/github.com eth/src/golang.org eth/src/github.com/ethereum
4.進入 eth/src/github.com/ethereum 文件夾
cd eth/src/github.com/ethereum
5.經過git下載ethereum,地址是 https://github.com/ethereum/go-ethereum.git
command:
git clone https://github.com/ethereum/go-ethereum.git
output:
thereum/go-ethereum.git Cloning into 'go-ethereum'... remote: Counting objects: 71480, done. remote: Total 71480 (delta 0), reused 0 (delta 0), pack-reused 71480 Receiving objects: 100% (71480/71480), 97.76 MiB | 1.81 MiB/s, done. Resolving deltas: 100% (47359/47359), done.
出現以上輸出表示下載成功了。
6.打開ide go-land
鍵盤按住:command+空格
搜索go-land,打開
7.載入eth文件夾
點擊 Open Project ,找到 /Users/qingyun.yu/go/eth 文件夾,點擊肯定便可
8.建立 genesis.json 文件(初始化須要的一些參數)
genesis.json:
{ "config": { "chainId": 666, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }, "coinbase" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x40000", "extraData" : "", "gasLimit" : "0xffffffff", "nonce" : "0x0000000000000042", "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00", "alloc": { } }
9.進入 Edit Configurations
點擊 Edit Configurations ,出現如下界面
10.建立兩個 Go Build
點擊+號,而後點擊 Go Build ,出現下面的界面
配置下面的參數:
第一個go build(初始化一些信息):
其中 dev/data/02 是存儲數據的地方, private-geth/genesis.json 是初始化配置文件的地址,
第二個go build(運行以太坊客戶端,而且打開控制檯):
其中 666 爲你要加入鏈的編號,以太坊默認的鏈是1號, console 表示進入控制檯。
經過以上的配置,你就能夠使用ide進行debug調試了。