一、条件
1、设备:win7、win10
2、两台电脑均需要安装geth,安装教程见04windows中搭建以太坊私有链
注意:两台电脑的初始化配置文件genesis.json要相同。
二、启动geth
1、节点1
geth --datadir "C:\eth\geth\bin\PrivateChain" --nodiscover --networkid 333 --ipcdisable --port 3333 --rpc --rpcport 4444 console
2、节点2
geth --datadir "C:\eth\geth\bin\PrivateChain" --nodiscover --networkid 333 --ipcdisable --port 1111 --rpc --rpcport 2222 console
三、查看节点账户
eth.accounts
net.peerCount
四、连接配置
注意:关掉杀毒软件和防火墙
1、查看节点2的enode
admin.nodeInfo.enode
2、在节点1中添加节点2(和上面查看的enode不同,请忽略)
admin.addPeer("***")
3、查看节点连接情况
net.peerCount
五、两节点间进行转账
1、节点1和节点2未转账前的区块高度
节点1
节点2
2、转账
//转账数量
amount = web3.toWei(5, 'ether')
//解密
personal.unlockAccount(eth.accounts[0])
//转账,to后面的是另一节点的一个账户名,可用eth.accounts获得
eth.sendTransaction({from:eth.accounts[0],to:'0x36db211a8e37fcb362896cd13a17c322fd04aa6f',value:amount})
3、转账查看
执行miner.start()后才会刷新账户,并且同步区块。
miner.start()