CentOS7 搭建以太坊私有链

2018-01-08 健励信息

1. 安装Go语言

yum install -y golang1
go version1

2. 安装Ethereum

下载

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

编译

tar -zxvf v1.7.3.tar.gzcd go-ethereum-1.7.3make123

3. 运行Ethereum

cd build/bin/1

配置文件

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

初始化

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

运行

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

4. 使用Ethereum

创建帐户

personal.newAccount()1

查询帐户

personal.listAccounts1

查询帐户余额

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

挖矿

miner.start(1)1

停止

miner.stop()1

参考

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