geth查看是否是全节点_以太坊geth交互-初始化

1.geth初始化

1.下载好geth后,为防止出现gas不够的情况。

f3d76256bcda35b6bcdcfff430669044.png

解决方法:初始化时,"chainId":为大一点的值。设置genesis.json如下:

{
"config": {
"chainId": 1000,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "0x400",
"gasLimit": "0x2fefd8",
"alloc": {
"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
"f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
}
}

初始化命令:

geth -datadir data init genesis.json

6be5938ff165bc80e39e0c02afd71faf.png

再次进入终端输入:

geth --datadir data --networkid 1101 --rpc  --rpcaddr 0.0.0.0 --rpcapi "web3,eth,personal,net"  --rpcport 8545 console

8b3f8b9aa0dfc6bf7eaa3b79191e9e34.png

2.geth初始操作

创建账户
personal.newAccount("0xa9436991e002986f58d948d79e737df190c4f26b")
查询账户列表
personal.listAccounts
eth.accounts
开始挖矿
miner.start()
设置挖矿地址
miner.setEtherbase(eth.accounts[0])
停止挖矿
miner.stop()
转币
eth.sendTransaction({from:sender, to:receiver, value: amount})
eth.sendTransaction({from:eth.coinbase, to:eth.accounts[1], value: web3.toWei(0.05, "ether")})
解锁
personal.unlockAccount("0xa9436991e002986f58d948d79e737df190c4f26b")
查询余额
eth.getBalance('0xB97168a67AB66E55B98B1439222Ee665E657fFc0')
查看节点信息
admin.nodeInfo
节点高度
eth.blockNumber
根据genesis.json初始化第一个区块
geth --datadir "./" init genesis.json
查看区块log
geth --datadir "./" --nodiscover console 2>>geth.log
实时跟踪log
tail -f geth.log
启动私链
geth --datadir "./" --nodiscover --rpc --rpcport "8546" --rpcapi "db,eth,net,web3,personal" --rpcaddr="[0.0.0.0](0.0.0.0)" --networkid 15 console 
2>>geth.log
geth --datadir "./" --nodiscover --rpc --rpcport "8545" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcaddr="0.0.0.0" --networkid 15 console 2>>geth.log
退出
exit
链接远程私链
geth attach http://60.8.103.54:8545 2>&1 console.log

10506094752d7732e80399cb2e8be2d6.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值