文章目录
1. git安装
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
查看版本号
git --version
git version 2.19.1
2. geth安装
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
获取geth 指令
geth --help
3. 导出配置文件
geth
--syncmode "fast"
--rpcapi="db,eth,net,web3,personal,web3"
--rpc --rpcaddr 192.168.0.1(内网ip)
--rpcport 3342
--rpccorsdomain "*"
--datadir "/mnt/www/walletdata/ethereum"
--txpool.journal "/mnt/www/walletdata/transactions.rlp"
--mine --miner.etherbase "0x000000"(miner地址)
--verbosity 3
--maxpeers 200
--maxpendpeers 200
--allow-insecure-unlock
--cache=8192 dumpconfig > "/mnt/www/walletdata/geth.toml"
下次直接使用下面指向来启动
--config /mnt/www/walletdata/geth.toml
4. 启动脚本
nohup geth
--syncmode "light"
--rpcapi="db,eth,net,web3,personal,web3"
--rpc
--rpcaddr 192.168.0.1
--rpcport 3342
--rpccorsdomain "*"
--datadir "/mnt/walletdata/ethereum"
--verbosity 3
--maxpeers 200
--maxpendpeers 200
--allow-insecure-unlock
--cache=8192 >eth.log 2>&1 &
全节点:--syncmode "fast"
轻节点:--syncmode "light"
开启挖矿:--mine
miner.start(1)
miner.stop()
挖矿默认指定地址:--miner.etherbase "0x00000000......"
指定txpool的存储目录,下次节点重启会再次广播交易池的交易:
--txpool.journal "/mnt/www/walletdata/transactions.rlp"
控制台启动:
geth attach ipc:walletdata/ethereum/geth.ipc
查看链接的节点:
admin.peers
查看节点的地址列表:
admin.peers.forEach(function(p) {console.log(p.network.remoteAddress);})
查看本地节点信息,为了让其他节点链接:
admin.nodeInfo.enode
txpool.status
txpool.content
txpool.inspect
5. 转账
personal.unlockAccount('xxx')
eth.sendTransaction({from:'xxx',to:'xxx',value:web3.toWei(0.01)})
6. pending状态的单子处理
personal.unlockAccount("0x1111111111111111111","1234567890")
tx = eth.pendingTransactions[0]
eth.resend(tx, 20000000000, 21000)
7. 分叉后geth更新
sudo apt-get update
sudo apt-get install ethereum
apt-get install --only-upgrade geth
apt-get dist-upgrade // 更新已安装的软件包(识别并处理依赖关系的改变)
出现Please check that your locale settings:
echo "export LC_ALL=C" >> /root/.bashrc
source /root/.bashrc
8. 查看已连接节点数量
net.peerCount
9. 区块浏览器查询
10. 文档
https://ethereum.gitbooks.io/frontier-guide/content/installing_linux.html