0x01 一键安装脚本

- Ubuntu

  #!/bin/sh

  RunPath=~/tools/miner/swarm
  mkdir -p $RunPath/bee
  mkdir -p $RunPath/bee-clef
  mkdir -p $RunPath/exportSwarmKey

  # Install bee-clef
  wget -O $RunPath/bee-clef/bee-clef_0.4.12_amd64.deb https://github.com/ethersphere/bee-clef/releases/download/v0.4.12/bee-clef_0.4.12_amd64.deb
  sudo dpkg -i $RunPath/bee-clef/bee-clef_0.4.12_amd64.deb

  # Install bee 0.6.2
  wget -O $RunPath/bee/bee_0.6.1_amd64.deb https://github.com/ethersphere/bee/releases/download/v0.6.2/bee_0.6.2_arm64.deb
  sudo dpkg -i $RunPath/bee/bee_0.6.2_arm64.deb

  # Install bee 0.6.1
  #wget -O $RunPath/bee/bee_0.6.1_amd64.deb https://github.com/ethersphere/bee/releases/download/v0.6.1/bee_0.6.1_amd64.deb
  #sudo dpkg -i $RunPath/bee/bee_0.6.1_amd64.deb

  # Install bee 0.5.3
  #wget -O $RunPath/bee/bee_0.5.3_amd64.deb https://github.com/ethersphere/bee/releases/download/v0.5.3/bee_0.5.3_amd64.deb
  #sudo dpkg -i $RunPath/bee/bee_0.5.3_amd64.deb

  # See address
  sudo bee-get-addr > ./beeAddress.txt

  # Export Address Key
  #wget -O $RunPath/exportSwarmKey/export-swarm-key-linux-amd64 https://github.com/ethersphere/exportSwarmKey/releases/download/v0.1.0/export-swarm-key-linux-amd64
  #chmod +x $RunPath/exportSwarmKey/export-swarm-key-linux-amd64
  #sudo cat /var/lib/bee/password | xargs sudo $RunPath/exportSwarmKey/export-swarm-key-linux-amd64 /var/lib/bee/keys > privatekey.txt

  # Download cashout.sh
  wget -O $RunPath/cashout.sh https://gist.githubusercontent.com/ralph-pichler/3b5ccd7a5c5cd0500e6428752b37e975/raw/7ba05095e0836735f4a648aefe52c584e18e065f/cashout.sh
  chmod +x $RunPath/cashout.sh

  # Export Swarm Key
  sudo bee-clef-keys
  sudo mv ~/bee* $RunPath/

- CentOS

  #!/bin/sh

  RunPath=~/tools/miner/swarm
  mkdir -p $RunPath/bee
  mkdir -p $RunPath/bee-clef
  mkdir -p $RunPath/exportSwarmKey

  # Install bee-clef
  wget -O $RunPath/bee-clef/bee-clef_0.4.12_amd64.rpm https://github.com/ethersphere/bee-clef/releases/download/v0.4.12/bee-clef_0.4.12_amd64.rpm
  sudo rpm -i $RunPath/bee-clef/bee-clef_0.4.12_amd64.rpm

  # Install bee 0.6.2
  wget -O $RunPath/bee/bee_0.6.1_amd64.rpm https://github.com/ethersphere/bee/releases/download/v0.6.2/bee_0.6.2_amd64.rpm
  sudo rpm -i $RunPath/bee/bee_0.6.2_amd64.rpm

  # Install bee 0.6.1
  #wget -O $RunPath/bee/bee_0.6.1_amd64.rpm https://github.com/ethersphere/bee/releases/download/v0.6.1/bee_0.6.1_amd64.rpm
  #sudo rpm -i $RunPath/bee/bee_0.6.1_amd64.rpm

  # Install bee 0.5.3
  #wget -O $RunPath/bee/bee_0.5.3_amd64.rpm https://github.com/ethersphere/bee/releases/download/v0.5.3/bee_0.5.3_amd64.rpm
  #sudo rpm -i $RunPath/bee/bee_0.5.3_amd64.rpm

  # See address
  sudo bee-get-addr > ./beeAddress.txt

  # Export Address Key
  wget -O $RunPath/exportSwarmKey/export-swarm-key-linux-amd64 https://github.com/ethersphere/exportSwarmKey/releases/download/v0.1.0/export-swarm-key-linux-amd64
  chmod +x $RunPath/exportSwarmKey/export-swarm-key-linux-amd64
  sudo cat /var/lib/bee/password | xargs sudo $RunPath/exportSwarmKey/export-swarm-key-linux-amd64 /var/lib/bee/keys > privatekey.txt

  # Download cashout.sh
  wget -O $RunPath/cashout.sh https://gist.githubusercontent.com/ralph-pichler/3b5ccd7a5c5cd0500e6428752b37e975/raw/7ba05095e0836735f4a648aefe52c584e18e065f/cashout.sh
  chmod +x $RunPath/cashout.sh

  # Export Swarm Key
  #sudo bee-clef-keys
  #sudo mv ~/bee* $RunPath/

0x02 一些基础操作整理

- 1、简单命令行

  # 查询当前节点余额
  curl localhost:1635/chequebook/balance | jq

  # 查询对等节点余额
  curl localhost:1635/balances | jq

  # 查询支票
  curl localhost:1635/chequebook/cheque | jq

  # 查询有效支票
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[].lastreceived'

  # 统计有效票总数
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[].lastreceived' | grep "payout" | wc -l

  # 支票兑换bzz - 后面的地址为对等节点的peer
  curl -XPOST http://localhost:1635/chequebook/cashout/d7881307e793e389642ea733451db368c4c9b9e23f188cca659c8674d183a56b

  # 支票兑换状态
  curl http://localhost:1635/chequebook/cashout/d7881307e793e389642ea733451db368c4c9b9e23f188cca659c8674d183a56b | jq

  # 取出bzz到节点钱包
  # 支票额度与BZZ兑换比例
  # 1,000,000,000,000,000,000 = 1BZZ
  curl -XPOST http://localhost:1635/chequebook/withdraw\?amount\=1000 | jq

  # 将bzz继续存入支票簿
  curl -XPOST http://localhost:1635/chequebook/deposit\?amount\=1000 | jq

- 2、一句话命令行,需要自编脚本的可以自行修改

  # 取出peer地址
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[]' | grep "peer" | sed -e 's/\"peer\": \"//g' | sed -e 's/\",//g'

  # 取有效票的peer地址以及支票额度
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[]' | jq 'if .lastreceived.payout > 0 then "true \(.peer) \(.lastreceived.payout) " else "false" end'

  # 统计有效票的数量
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[]' | jq 'if .lastreceived.payout > 0 then "true \(.peer) \(.lastreceived.payout) " else "false" end' | grep true | wc -l

  # 查看支票状态
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[]' | \
      jq 'if .lastreceived.payout > 0 then "true \(.peer) \(.lastreceived.payout) " else "" end' | \
      grep "true" | \
      awk '{print "http://localhost:1635/chequebook/cashout/"$2}' | xargs curl | jq '.'

  # 兑换支票
  curl -s http://localhost:1635/chequebook/cheque | jq '.lastcheques[]' | \
      jq 'if .lastreceived.payout > 0 then "true \(.peer) \(.lastreceived.payout) " else "" end' | \
      grep "true" | \
      awk '{print "http://localhost:1635/chequebook/cashout/"$2}' | xargs curl -X POST | jq '.'

- 3、cashout.sh 脚本

  # 支票管理脚本下载
  wget -O cashout.sh https://gist.githubusercontent.com/ralph-pichler/3b5ccd7a5c5cd0500e6428752b37e975/raw/cashout.sh

  # 查看支票
  ./cashout.sh

  # 兑现所有支票
  ./cashout.sh cashout-all 5

0x03 其它


- v0.5.3 手动引导节点,可以自行添加到bee.yaml配置文件,无需手动curl

  curl -X POST localhost:1635/connect/ip4/157.122.62.228/tcp/1634/p2p/16Uiu2HAmUvTfJ7qVTtyGbcc6QNzvdC5Fj4qyQLgPL8KMHPW7GeWA
  curl -X POST localhost:1635/connect/ip4/219.137.67.229/tcp/1634/p2p/16Uiu2HAmEq2DgfDSnkoZZHRWEnovgQcoAYebwxPDi1M4k3qHUwuq
  curl -X POST localhost:1635/connect/ip4/47.241.6.61/tcp/1634/p2p/16Uiu2HAmVj4MJr1bzooQHUAbWDivuh6uuNCaNgJzeJoyzxETNrBq
  curl -X POST localhost:1635/connect/ip4/120.24.145.255/tcp/1634/p2p/16Uiu2HAmJGFBoYHvtnW4xYfFmHmH4CyJBPpBHc7Ri92kZctncJt4
  curl -X POST localhost:1635/connect/ip4/121.89.234.168/tcp/1634/p2p/16Uiu2HAmTKweMDg9jtsNkx8sxmAHwY3d7Eq2vMwps2aYEJC7g1V2