Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

创建私链

  1. 定位到数据目录

cd D:\workproject\blockchain\geth_data

  1. 初始化

geth --datadir smallchain init genesis.json

geth --datadir smallchain --http --http.api net,web3,db,personal --identity smallc --networkid 666 --corsdomain *

//genesis.json
{
    "config": {
        "chainId": 77 //链ID 随便起 和主链、测试连不同就OK
    },
    "alloc": {
        "0xc7c4f9a0Cd0a3e45348c5ed8c3909C69aA9FA8fC": { "balance": "10000000000000000000000" } //创世块分配的账户及余额
    },
    "difficulty": "9000", //挖矿难度
    "gasLimit": "2100000" //汽油费
}


{
    "config": {
        "chainId": 123,
        "homesteadBlock": 0,
        "eip150Block": 0,
        "eip155Block": 0,
        "eip158Block": 0,
        "byzantiumBlock": 0,
        "constantinopleBlock": 0,
        "petersburgBlock": 0,
        "istanbulBlock": 0
    },
    "alloc": {},
    "coinbase": "0x0000000000000000000000000000000000000000",
    "difficulty": "0x2000",
    "extraData": "",
    "gasLimit": "0x2fefd8",
    "nonce": "0x0000000000000042",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp": "0x00"
}