美文网首页
Mac 搭建以太坊私链

Mac 搭建以太坊私链

作者: 代码侯 | 来源:发表于2018-07-30 19:59 被阅读0次

1.新建工作目录

mkdir geth

2.在工作目录下创建创世区块配置文件

cd geth
vim genesis.json

3.编辑创世区块配置文件

{
    "coinbase": "0x0000000000000000000000000000000000000000",
    "config": {
        "homesteadBlock": 0,
                "chainId": 110,
                "eip155Block": 0,
                "eip158Block": 0
    },
    "difficulty": "0x20000",
    "extraData": "0x",
    "gasLimit": "0x2FEFD8",
    "mixhash": "0x00000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "alloc": {}
}

4.初始化,将上面创世区块的信息写入到区块链中

mkdir db

geth --datadir "./db" init genesis.json

此时会在db文件夹中生成geth和keystore两个文件夹,目录结构如下:

.
├── db
│   ├── geth
│   │   ├── chaindata
│   │   │   ├── 000001.log
│   │   │   ├── CURRENT
│   │   │   ├── LOCK
│   │   │   ├── LOG
│   │   │   └── MANIFEST-000000
│   │   └── lightchaindata
│   │       ├── 000001.log
│   │       ├── CURRENT
│   │       ├── LOCK
│   │       ├── LOG
│   │       └── MANIFEST-000000
│   └── keystore
└── gensis.json

5.启动节点

geth --datadir "./db" --networkid 110  --rpc console

6.创建账户

personal.newAccount()

输入账户密码,即可得到账户的地址,再次执行上面的命令,创建第二个账户

7.开始挖矿

运行效果

INFO [07-30|19:30:50.437] Maximum peer count                       ETH=30 LES=0 total=30
INFO [07-30|19:30:50.453] Starting peer-to-peer node               instance=Geth/v1.8.12-stable/darwin-amd64/go1.10.3
INFO [07-30|19:30:50.453] Allocated cache and file handles         database=/Users/alec/ethereum/myeth/db/geth/chaindata cache=768 handles=1024
INFO [07-30|19:30:50.467] Initialised chain configuration          config="{ChainID: <nil> Homestead: 5 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: <nil> EIP158: <nil> Byzantium: <nil> Constantinople: <nil> Engine: unknown}"
INFO [07-30|19:30:50.467] Disk storage enabled for ethash caches   dir=/Users/alec/ethereum/myeth/db/geth/ethash count=3
INFO [07-30|19:30:50.467] Disk storage enabled for ethash DAGs     dir=/Users/alec/.ethash                       count=2
INFO [07-30|19:30:50.467] Initialising Ethereum protocol           versions="[63 62]" network=1981
INFO [07-30|19:30:50.468] Loaded most recent local header          number=0 hash=6b4ab3…6618a5 td=131072
INFO [07-30|19:30:50.468] Loaded most recent local full block      number=0 hash=6b4ab3…6618a5 td=131072
INFO [07-30|19:30:50.468] Loaded most recent local fast block      number=0 hash=6b4ab3…6618a5 td=131072
INFO [07-30|19:30:50.468] Regenerated local transaction journal    transactions=0 accounts=0
INFO [07-30|19:30:50.469] Starting P2P networking
INFO [07-30|19:30:50.470] RLPx listener up                         self="enode://c0373a6f3ffc624b555a7afb52a425e13412f5034c7244bf6998301080e9257588d3dc8c67287d896961d90bb7e85ee7c2f7997d6debf9c024459574354a1315@[::]:30303?discport=0"
INFO [07-30|19:30:50.473] IPC endpoint opened                      url=/Users/alec/ethereum/myeth/db/geth.ipc
INFO [07-30|19:30:50.473] HTTP endpoint opened                     url=http://0.0.0.0:8545                    cors=* vhosts=localhost
INFO [07-30|19:30:50.483] Transaction pool price threshold updated price=18000000000
INFO [07-30|19:30:50.483] Starting mining operation
INFO [07-30|19:30:50.483] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=188.661µs
Welcome to the Geth JavaScript console!
屏幕快照 2018-07-30 下午7.50.58.png

出现小锤子说明已经开始挖矿了!

相关文章

网友评论

      本文标题:Mac 搭建以太坊私链

      本文链接:https://www.haomeiwen.com/subject/qxkqvftx.html