状态检查
主页
检查运行是否正常
1
   | curl -s http://localhost:1635/health
   | 
 
查看当前bee节点的地址
1
   | curl -s localhost:1635/addresses | jq .ethereum
   | 
 
查看链接了多少个peer
1
   | curl -s http://localhost:1635/peers | jq '.peers | length'
   | 
 
查看网络拓扑
1
   | curl -X GET http://localhost:1635/topology | jq
   | 
 
上传文件
上传文件,返回的是一个hash值
1 2
   | curl -F file=@bee.jpg http://localhost:1633/files {"reference":"02a03340405f30c1027b885ee39903fb394ba8909e98029dd6c14371437edafc"}
   | 
 
1
   | curl --data-binary @bee.jpg  -H "Content-Type: video/jpg" "http://localhost:1633/files?name=bee.jpg"
   | 
 
下载文件
1 2
   | curl -OJ http://localhost:1633/files/042d4fe94b946e2cb51196a8c136b8cc335156525bf1ad7e86356c2402291dd4 https://gateway.ethswarm.org/files/042d4fe94b946e2cb51196a8c136b8cc335156525bf1ad7e86356c2402291dd4
   | 
 
特别注意:不要传一些重要数据到swarm除非已经加密,因为上传上去之后的所有文件都是公开的,只要知道hash就能下载。
上传文件夹
比如有一个前端vue项目,需要上传到swarm
项目构建
把需要上传的文件夹dist打包
1 2
   | cd dist tar -cf ../hello-swarm.tar .
   | 
 
- 把hello-swarm.tar包上传到swarm
 
1 2 3 4 5
   | curl \      -X POST \      -H "Content-Type: application/x-tar" \      -H "Swarm-Index-Document: index.html" \      --data-binary @hello-swarm.tar http://localhost:1633/dirs
   | 
 
{“reference”:“b2afd8fa4995be121ba6e6cf544d035e07a2b4b775648b5549b14f82e15c5bea”}
访问主页:
http://localhost:1633/bzz/b2afd8fa4995be121ba6e6cf544d035e07a2b4b775648b5549b14f82e15c5bea/index.html
支票信息API
查询当前bee节点的余额
1
   | curl localhost:1635/chequebook/balance | jq
   | 
 
查看每个节点(当前bee节点连接的)的余额
1
   | curl localhost:1635/balances | jq
   | 
 
查看结算信息
1
   | curl localhost:1635/settlements | jq
   | 
 
查看支票信息
1
   | curl localhost:1635/chequebook/cheque | jq
   | 
 
支票兑换(地址是上一个命令中显示的地址)
1
   | curl -XPOST http://localhost:1635/chequebook/cashout/d7881307e793e389642ea733451db368c4c9b9e23f188cca659c8674d183a56b
   | 
 
查看支票的兑换状态
1
   | curl http://localhost:1635/chequebook/cashout/d7881307e793e389642ea733451db368c4c9b9e23f188cca659c8674d183a56b | jq
   | 
 
gBZZ提现
1
   | curl -XPOST http://localhost:1635/chequebook/withdraw\?amount\=1000 | jq
   | 
 
管理支票脚本
下载官方的脚本
1
   | wget -O cashout.sh https://gist.githubusercontent.com/ralph-pichler/3b5ccd7a5c5cd0500e6428752b37e975/raw/cashout.sh
   | 
 
添加可执行权限
列出所有的没有兑换的支票信息
当超过5BZZ时兑换所有支票:
1
   | ./cashout.sh cashout-all 5
   |