需要输入两次key密码(重要,需要记住)
bee start --verbosity 5 --swap-endpoint https://rpc.slock.it/goerli --debug-api-enable
将会输出
WARN[2021-04-21T18:21:02+08:00] cannot continue until there is at least 10 BZZ available on 5763e8fea803caa7b2d6c18709ef36b1b54fc1cf
WARN[2021-04-21T18:21:02+08:00] get your Goerli ETH and Goerli BZZ now via the bzzaar at https://bzz.ethswarm.org/?transaction=buy&amount=10&slippage=30&receiver=0x5763e8fea803caa7b2d6c18709ef36b1b54fc1cf
最后得receiver为我们钱包地址,提示我们没有ETH和GZZ,先CTRL+C终止
https://faucet.goerli.mudit.blog/
http://goerli-faucet.slock.it/
https://faucet.ethswarm.org/
从水龙头获取代币,建议使用第一个最高可以获取87.5个gEth,需要从twitter发个包含地址推文
需要专门得工具exportSwarmKey
wget https://github.com/ethersphere/exportSwarmKey/releases/download/v0.1.0/export-swarm-key-linux-386
./export-swarm-key-linux-386 /root/.bee/keys/ 你的密码
导入账户-》私钥-》选择我们得~/.bee/keys/目录下得swarm.key
浏览器打开
https://bzz.ethswarm.org/?transaction=buy&amount=10&slippage=30&receiver=0x5763e8fea803caa7b2d6c18709ef36b1b54fc
,选择Connect to your MetaMask Wallet,选择连接我们刚刚导入账户,输出要转换得gBzz数量,点击左下角得Get G-ETH ,再点击EXCAHNGE,
去以太坊浏览器查看交易情况
https://goerli.etherscan.io/address/0x5763e8fea803caa7b2d6c18709ef36b1b54fc1cf
nohup bee start \
--swap-endpoint https://rpc.slock.it/goerli \
--debug-api-enable \
--verbosity 5 \
--swap-enable \
--api-addr=:1633 \
--debug-api-enable \
--debug-api-addr=:1635 \
--p2p-addr=:1634 \
--resolver-options "https://cloudflare-eth.com" \
--password 你的密码 > bee.log 2>&1 &
主要通过http接口发送请求,API请参考
curl -s http://localhost:1635/peers | jq '.peers | length'
curl -X GET http://localhost:1635/topology | jq
echo "hello" >test.txt
curl -F [email protected] http://localhost:1633/files
{"reference":"303ce5f9864fd18ee5234c40d5a8df8671db22d68ecc1d4788b11b769fd58792"}
curl -OJ http://localhost:1633/files/303ce5f9864fd18ee5234c40d5a8df8671db22d68ecc1d4788b11b769fd58792
https://gateway.ethswarm.org/files/303ce5f9864fd18ee5234c40d5a8df8671db22d68ecc1d4788b11b769fd58792
curl -F [email protected] -H "Swarm-Encrypt: true" http://localhost:1633/files
{"reference":"b75426db4bebf679abe0e3989617481ffabb955f9d655b37835b7a616090375197f03d3564edc54e9d848db85aea8cb93aa9472ccaa27c47f2fde298d80b6462"}
返回得128个字符hash,前64就是原来得reference,后64个字符是密钥
curl -OJ http://localhost:1633/files/b75426db4bebf679abe0e3989617481ffabb955f9d655b37835b7a616090375197f03d3564edc54e9d848db85aea8cb93aa9472ccaa27c47f2fde298d80b6462
curl -H "swarm-pin: true" --data-binary @test.txt localhost:1633/files\?test.txt
{"reference":"32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67"}
curl -XDELETE http://localhost:1633/pin/files/32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67
{"message":"OK","code":200}
再次执行
curl -XDELETE http://localhost:1633/pin/files/32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67
{"message":"cannot unpin","code":500}
curl -XPOST http://localhost:1633/pin/files/32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67
curl http://localhost:1633/pin/chunks/32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67
本地固定可确保您自己的节点不会删除上传的文件。但是其他存储您的数据的节点(因为它们属于其职责范围内)可能已删除了最近尚未访问的内容,以便腾出空间.
启动节点时带上–global-pinning-enable标志
bee start\
--verbosity 5 \
--swap-endpoint https://rpc.slock.it/goerli \
--global-pinning-enable \
--debug-api-enable
和本地pin一样
curl -H "swarm-pin: true" --data-binary @test.txt localhost:1633/files\?test.txt
{"reference":"32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67"}
如果请求一个已经由其存储节点进行垃圾回收的数据(chunk),则存储节点将使用PSS向该前缀所定义的Swarm邻域节点发送消息
先找出我们的目标前缀
curl -s http://localhost:1635/addresses | jq .overlay
"aeae412998fef1d9c8b8e93df53aaa572fc909ca745a2a78103782ab68b838ad
获取overlay地址的前两个字节aeae,并在查看文件时将其带在target参数中.
curl http://localhost:1633/files/32eb13ba65fe78ba98e5d96f65cdb7cfea93d8e3b4ba1c7cc34bc71c8bb15b67?target=aeae
现在,即使我们的数据被删除,它们也将由我们的本地Bee节点在网络中修复,并且将始终对整个集群可用!
启动bee时设置–swap-enable 和 --swap-endpoint标志
bee start \
--verbosity 5 \
--swap-enable \
--swap-endpoint https://rpc.slock.it/goerli \
--debug-api-enable
生成文件并上传
dd if=/dev/urandom of=/tmp/test.txt bs=1M count=20
curl -F file=@/tmp/test.txt http://localhost:1633/files
查看支票薄账户余额
curl localhost:1635/chequebook/balance | jq
查看每个peer的余额
curl localhost:1635/balances | jq
查看支票接收和发送数量
curl localhost:1635/settlements | jq
{
"totalreceived": 1304000000000,
"totalsent": 8983000000000,
"settlements": [
{
"peer": "200853fc86af3ffdd5c134d3a81dc8a957989cf4af770feeee7cda1c302787c7",
"received": 0,
"sent": 8983000000000
},
{
"peer": "ae700c55b4f491901f7055506892efa12241792b512256c52fc078a7d0ac9a94",
"received": 1120000000000,
"sent": 0
},
{
"peer": "ae226dc2e13470a478ee9daf7cff451b10ccce67949bf838627ccee31852b3da",
"received": 184000000000,
"sent": 0
}
]
}
查看支票薄详情
curl localhost:1635/chequebook/cheque | jq
{
"lastcheques": [
{
"peer": "200853fc86af3ffdd5c134d3a81dc8a957989cf4af770feeee7cda1c302787c7",
"lastreceived": null,
"lastsent": {
"beneficiary": "0x647b459c7dA0942A72F8DE7243F61d9873d1a6bd",
"chequebook": "0xfE47B51C5D21C4709020d81fd5182551e3B094B6",
"payout": 8983000000000
}
},
{
"peer": "ae700c55b4f491901f7055506892efa12241792b512256c52fc078a7d0ac9a94",
"lastreceived": {
"beneficiary": "0x5763e8fea803CAa7b2D6C18709Ef36b1b54fc1Cf",
"chequebook": "0x322F631f336f4fEbFdA1e5a2a5CDF81FbB6bbAD6",
"payout": 1120000000000
},
"lastsent": null
},
{
"peer": "ae226dc2e13470a478ee9daf7cff451b10ccce67949bf838627ccee31852b3da",
"lastreceived": {
"beneficiary": "0x5763e8fea803CAa7b2D6C18709Ef36b1b54fc1Cf",
"chequebook": "0xcfBCa130f7bAf4e4A08480d6Fb5E6Bee5b0a1C7e",
"payout": 184000000000
},
"lastsent": null
}
]
}
兑现(POST请求)
curl -XPOST http://localhost:1635/chequebook/cashout/ae700c55b4f491901f7055506892efa12241792b512256c52fc078a7d0ac9a94
查看兑现状态(GET请求)
curl http://localhost:1635/chequebook/cashout/ae700c55b4f491901f7055506892efa12241792b512256c52fc078a7d0ac9a94 | jq
将token从合约提现到个人账户
curl -XPOST http://localhost:1635/chequebook/withdraw\?amount\=金额 | jq