CentOS7 搭建以太坊私有链

1. 安装Go语言

yum install -y golang
go version

2. 安装Ethereum

下载

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

编译

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

3. 运行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

4. 使用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

你可能感兴趣的:(Ethereum)