ubuntu 17.10安装
sudo apt upgrade -y
sudo apt install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install ethereum
sudo apt install solc -y
一条一条复制黏贴,好,你的环境已经搭好了,继续下一步
创建创世区块
mkdir -p ethereum && cd ethereum
vim genesis.json
geth init genesis.json
下面这段拷到genesion.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": { }
}
创建两个矿工: 当前目录 /root/ethereum
geth --datadir miner1 init genesis.json
geth --datadir miner2 init genesis.json
编写运行脚本:
这里我找了一天,后来才发现路径写错了,一直以为是什么情况,我真的是太傻了
没看到有写成脚本的,自己试了一下,给自己挖了个大坑,算是个教训吧
cd ~/ethereum
vim miner1.sh
#脚本内容,下面这段拷进去,记得修改自己的ip,修改ip,ip
#!/bin/bash
geth --networkid 15 --datadir miner1 --rpc --rpcaddr 45.63.61.235 --rpcport 8546 --nodiscover --ipcpath "/root/.ethereum/geth.ipc" #注意这个路径,有个点(我系统的默认路径)chmod +x miner1.sh
cd ~/ethereum
vim miner2.sh
#脚本内容,下面这段拷进去,,记得修改自己的ip,修改ip,ip
#!/bin/bash
geth --networkid 15 --datadir miner2 --rpc --rpcaddr 45.63.61.235 --rpcport 8545 --port "30304" --nodiscover --ipcpath "/root/ethereum/miner2/geth.ipc" #注意这个路径,没有点chmod +x miner2.sh
./miner1.sh
#再开一个终端
geth attach #通过这个终端来操作
personal.newAccount("123456") # 输入自己想要的密码,记好密码,别忘记了
personal.newAccount("123456") # 创建两个账户,方便后续操作
miner.setEtherbase(eth.accounts[0])
miner.start(4) # 4代表cpu核数,填1就行,我买的4核,就填4了,不用白不用
重要:执行之后,会如下结果,等DAG达到一百再操作,一百再操作,操作,作。出现