以太坊私网建立 (3) - 通过创世区块(genesis block)来初始化区块链

准备工具:

  • geth
  • eth钱包下载:https://github.com/ethereum/mist/releases
cd ~/Library/Ethereum/
cat > genesis.json
{
    "nonce": "0x0000000000000042",
    "difficulty": "0x020000",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
    "gasLimit": "0x4c4b40",
  "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "alloc": {
        "0x0000000000000000000000000000000000000001": {"balance": "111111111"},
        "0x0000000000000000000000000000000000000002": {"balance": "222222222"}
    }
}



geth init genesis.json


// 主网id是1,测试网络是2/3/4.

geth --networkid 10 --rpc --rpcapi "admin,debug,eth,miner,net,personal,shh,txpool,web3" rpcaddr "0.0.0.0" --rpccorsdomain "*" --nodiscover --dev console

打开, mist 钱包 ,自动进入私链

创建钱包;

另开一个终端:

geth attach 'http://127.0.0.1:8545'

miner.start(1)

//如果出现端口被占用
lsof -i:30303
//找到pid
kill -9 pid
//如果没有lsof 的话..
brew install lsof

你可能感兴趣的:(以太坊私网建立 (3) - 通过创世区块(genesis block)来初始化区块链)