下载文件并上传服务器解压:Downloads | Go Ethereum
?
然后把geth复制到/usr/bin目录下面,我们就可以使用geth命令了,geth version,出现下的界面,表示成功。?
?
{
"config": {
"chainId": 666,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5ddf8f3e",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x00002",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": { },
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
然后执行初始化区块的命令:
geth --datadir /usr/local/gethNodedata init /usr/local/gethNodedata/first.json
?初始化成功?
启动节点, 进入控制台,然后创建挖矿账户 进行挖矿
geth --http --http.addr 0.0.0.0 --nodiscover --datadir "/usr/local/gethNodedata" --port 30303 --http.api "personal,eth,net,web3,admin,ethash,miner" --http.port 18545 --http.corsdomain "*" --networkid 666 --ipcdisable --miner.gaslimit 2000000000 console 2>>/usr/local/gethNodedata/geth.log
//创建初始账户
personal.newAccount("test")
//开启挖矿 线程1个
miner.start(1)
//获取当前区块高度
eth.blockNumber
//获取地址账户余额
eth.getBalance("0x4ec1ed38a950edb10aba057719a702")
停止挖矿
miner.stop()
exit 退出控制台,同时也听着了geth进程
把进程转入后台执行
nohup geth --http --http.addr 0.0.0.0 --nodiscover --datadir "/usr/local/gethNodedata" --port 30303 --http.api "personal,eth,net,web3,admin,ethash,miner" --http.port 8545 --http.corsdomain "*" --networkid 666 --ipcdisable --mine --miner.gasprice 0 --miner.threads 1 --miner.gaslimit 2000000000 --allow-insecure-unlock 2>>/usr/local/gethNodedata/geth.log &
|