git clone https://github.com/forkchain/alpha.git
npm install
启动节点 1
HTTP_PORT=3001 P2P_PORT=6001 npm start
启动节点 2
HTTP_PORT=3002 P2P_PORT=6002 npm start
启动节点 3
HTTP_PORT=3003 P2P_PORT=6003 npm start
curl -H "Content-type:application/json" --data '{"peer" : "ws://localhost:6001"}' http://localhost:3001/addPeer
curl -H "Content-type:application/json" --data '{"peer" : "ws://localhost:6002"}' http://localhost:3001/addPeer
curl -H "Content-type:application/json" --data '{"peer" : "ws://localhost:6003"}' http://localhost:3001/addPeer
curl http://localhost:3001/peers
curl http://localhost:3001/g
curl http://localhost:3001/blocks/all
curl http://localhost:3002/blocks/all
curl http://localhost:3003/blocks/all
新建用户
node newuser.js
你要把助忆词和地址抄在安全的地方,key 文件里仅仅保存私钥。
+--------------+---------------------------------------------------------------------------------------+
| mnemonic | analyst merit gown expect lake crouch either radio achieve provide half total |
| Privatekey | 5JdGzR28pdh6c3vKrwLuQvWXbznJmrPwE81qurSVZzf8SwCtsDY |
| Publickey | GPH6HqQmNUBb3AqTfW7MtBqVCPXDJuKnZVEeyxPNk64sE6QYQKyH5 |
| Address | GPH9Jw8v7vmqKTaMjJpac2xefehQ7d9nJkAm |
+------------ +---------------------------------------------------------------------------------------+
显示用户
node showuser.js
这是你的信息
+--------------+---------------------------------------------------------------------------------------+
| Privatekey | 5JdGzR28pdh6c3vKrwLuQvWXbznJmrPwE81qurSVZzf8SwCtsDY |
| Publickey | GPH6HqQmNUBb3AqTfW7MtBqVCPXDJuKnZVEeyxPNk64sE6QYQKyH5 |
| Address | GPH9Jw8v7vmqKTaMjJpac2xefehQ7d9nJkAm |
+------------ +---------------------------------------------------------------------------------------+
node msg.js haha localhost 3001
欢迎关注公众号 ForkChain
欢迎进入芥末圈
区块链的部分是我自己写的,p2p 这部分主要来源于 https://github.com/zfzGit/P2PNodejs/blob/master/main.js 项目。
1
Loki666 2019-01-17 10:12:55 +08:00 via iPhone
很强可以加一下 wx 交流一下吗? wx:vilink
|