err="etherbase address must be explicitly specified"
如果要初始化区块链的话就用创始区块
如果通过创世区块来初始化区块链的话,首先需要一个初始化区块链的json文件,如下。
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "4",
"gasLimit": "2100000",
"alloc": {
"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": {
"balance": "300000"
},
"f41c74c9ae680c1aa78f42e5647a62f353b7bdde": {
"balance": "400000"
}
}}
config, difficulty, gasLimit, alloc创始区块文件中,这几个文件是必须的。
初始化区块链,并且创建一个文件夹来存储区块数据
geth init genesis.json --datadir private_data
打开终端
geth --networkid 888 --datadir private_data console
查看余额
> eth.getBalance("7df9a875a174b3bc565e6424a0050ebc1b2d1d82")
300000>
开始 mining
> miner.start()
INFO [10-15|07:57:15] Updated mining threads threads=0
INFO [10-15|07:57:15] Transaction pool price threshold updated price=18000000000
ERROR[10-15|07:57:15] Cannot start mining without etherbase err="etherbase address must be explicitly specified"
Error: etherbase missing: etherbase address must be explicitly specified
at web3.js:3104:20
at web3.js:6191:15
at web3.js:5004:36
at <anonymous>:1:1
>
如果你直接挖矿,会出现上面的错误。需要设置一个挖矿的账号。
> miner.setEtherbase("7df9a875a174b3bc565e6424a0050ebc1b2d1d82")true
>
好了,那么接下来就可以开始挖矿了,看起来和写起来都是相对比较简单的,大家加油努力学习,哈哈。