创世块使用:puppeth创建
参考:https://blog.youkuaiyun.com/code_segment/article/details/78160660
密码:123
node:
128809dd3d9fe616381ce21b868191ce90091c7e
04757dd260325fd85dfb1d8bdbf75f4f64e8f5a8
signer:
a0187bd2b4ba0235ed3327a38b45bb6ea60b3549
8a098a17c39d4cb1ce76dbabfdf02e935a558211
node1: geth --datadir ./data --port 2001 console
node2: geth --datadir ./data --port 2002 console
signer1后台运行: nohup geth --datadir ./data --mine --port 2003 --rpc --rpcaddr localhost --rpcport 8545 --rpcapi "db,eth,net,web3,admin,miner,personal,rpc,txpool" --unlock "a0187bd2b4ba0235ed3327a38b45bb6ea60b3549" --password "password.txt" &
signer1启动: geth --datadir ./data --rpc --rpcaddr localhost --rpcport 8545 --unlock "a0187bd2b4ba0235ed3327a38b45bb6ea60b3549" --password "password.txt"
signer2后台: nohup geth --datadir ./data --mine --port 2004 --unlock "8a098a17c39d4cb1ce76dbabfdf02e935a558211" --password "password.txt" &
signer2: geth --datadir ./data --port 2004 --unlock "8a098a17c39d4cb1ce76dbabfdf02e935a558211" console
创世块:geth init ./genesis.json --datadir "./chain"
1. geth --datadir chain --ipcpath chain/geth.ipc --nodiscover --rpc --rpcaddr localhost --rpcport 8080 --port 3000 --rpcapi "db,eth,net,web3,admin,miner,personal,rpc,txpool"
>>eth_output.log
2. geth attach ipc:http://localhost:8545
3.创建账户:web3.personal.newAccount("123456")
4.收益账户:eth.coinbase
5.查询余额:web3.fromWei(eth.getBalance(eth.coinbase), "ether")
web3.fromWei(eth.getBalance("0xa95222123d32b3515bf9f561feb6a2530522c3b9"), "ether")
6.修改挖矿收益账户:miner.setEtherbase("0xe6d5a0e6e02853547fabed0fb975bdac854e7d8b")
web3.fromWei(eth.getBalance("0x04757dd260325fd85dfb1d8bdbf75f4f64e8f5a8"), "ether")
7.txpool.status
{
pending: 0,
queued: 0
}
8.转账: web3.personal.unlockAccount(web3.eth.accounts[0],"123")
1: web3.personal.unlockAccount(web3.eth.accounts[0],"123456")
web3.eth.sendTransaction({from:web3.eth.accounts[0],to:web3.eth.accounts[1],value:web3.toWei(3,"ether")})
2: web3.eth.sendTransaction({from:"0xa0187bd2b4ba0235ed3327a38b45bb6ea60b3549",to:"0xa2a191ced99c200e7932f82d98828dd8e31f5421",value:web3.toWei(100,"ether")})
9 节点地址:admin.nodeInfo.enode
添加节点: admin.addPeer
("enode://0bab976daa9f669543c8f6192785643ada31fb6e77c5c3d885307b5dfe80001b55f77dde7ce8cf9f963dd87c03e90087fcf4a419ce5ab9aced9e928216f217d1@0.0.0.0:3000")
admin.addPeer("enode://57a8c11428981a827d7d2344ff26355d27dca54506a29a800b6204518d1730ac7f050a458fd48e3849abcad6117165fa1af32197060e1772005c93bd3920c5fc@[::]:30303")
admin.addPeer("enode://12f1cec16e2838a6e5acebe38a345f634262bf065e13c49f9fd456da2b2d914daa36b0cd4307e7d94b2f0f7ec1246e751b9e3ed22d549fa8b277f25c7933c370@[::]:2004")
poa:
1.启动节点
geth --datadir ./data --port 2001 console
geth --datadir ./data --ipcdisable --rpc --rpcaddr localhost --rpcport 8080 --port 3000 --rpcapi "db,eth,net,web3,admin,miner,personal,rpc,txpool" >>eth_output.log
2.启动并且解锁账户(signer签名者)注意 交易签名在siger1
geth --datadir ./data --rpc --rpcaddr localhost --rpcport 8080 --port 2003 --unlock "a0187bd2b4ba0235ed3327a38b45bb6ea60b3549" console
geth --datadir ./data --port 2004 --unlock "8a098a17c39d4cb1ce76dbabfdf02e935a558211" console
授权其他节点作为signer,当signer有多个时,需要大于51%完成签名,当需要删除某个singer时同样需要>51%,signer可以删除自己:
clique.propose("0x8a098a17c39d4cb1ce76dbabfdf02e935a558211",true)//添加
clique.discard("0x8a098a17c39d4cb1ce76dbabfdf02e935a558211") /删除