CentOS7 搭建以太坊私有链

                                         CentOS7 搭建以太坊私有链

下载并安装 golang

https://www.golangtc.com/download

这里要注意下 最新的golang 1.10 和go-ethereum-1.7.3 不太兼容

配置golang 环境 

vi /etc/profile
export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin
source /etc/profile
go  version

下载go-ethereum

https://github.com/ethereum/go-ethereum/archive/v1.7.3.tar.gz

解压编译:

tar -zxvf go-ethereum-1.7.3.tar.gz
cd go-ethereum-1.7.3
make

运行ethereum

cd build/bin/

配置文件

vi init.json
{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "200000000",
    "gasLimit": "2100000",
    "alloc": {
        "7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
        "f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
    }
}

初始化

./geth  --datadir "../../data/chain" init init.json

运行

./geth --rpc --rpccorsdomain "*" --datadir "../../data/chain" --port "30303" --rpcapi "db,eth,net,web3" --networkid 100000 console

使用ethereum

创建账户

personal.newAccount()

查询账户

personal.listAccounts

查询账户余额

web3.fromWei(eth.getBalance(eth.coinbase), "ether")

挖矿

miner.start(1)

停止

miner.stop()

帐户管理:https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts 
金矿管理:https://github.com/ethereum/go-ethereum/wiki/Mining

如果遇到miner.start()返回null 如何处理

miner.setEtherbase(eth.coinbase)

感谢https://blog.csdn.net/liuhelong/article/details/79220712

猜你喜欢

转载自blog.csdn.net/wangming520liwei/article/details/81172332
今日推荐