ethereum-在Ubuntu上搭建私有链

安装

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

genesis.json

{
  "config": {
        "chainId": 2018,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc": {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0xffff",
  "extraData"  : "",
  "gasLimit"   : "0x8ac7230489e80000",
  "nonce"      : "0x0000000000000032",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

初始化

geth --datadir ./tmpPrivate init ./genesis.json

启动

geth --datadir ./tmpPrivate --nodiscover --networkid 2018 --rpc --rpcaddr="0.0.0.0" --rpcport="8545" --rpcapi personal,db,eth,net,web3,miner --minerthreads 1 --rpccorsdomain "*" console 2>>.tmpPrivate\geth.log

通过privateKey创建账户

personal.importRawKey("d77278e071eb1a5ced7c5076d25ff00060b67cb0c49f19008e9565a6e29fcabd","password")

直接通过password创建账户
personal.newAccount("password")

查看本地账户

eth.accounts

开启挖矿

miner.start(1);

查询余额

eth.getBalance(eth.accounts[0])

以太币单位转换
web3.fromWei(eth.getBalance(eth.accounts[0]), 'ether')

https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu

posted @ 2018-05-18 11:12  holoyong  阅读(328)  评论(0编辑  收藏  举报