As your Bee forwards and serves chunks to its peers, it is rewarded in BZZ in the form of cheques. Once these cheques accumulate sufficient value, you may cash them out using Bee's API. This process transfers money from your peer's chequebooks into your own, which you can then withdraw to your wallet to do with as you please!
Do not cash out your cheques too regularly! Once a week is more than sufficient! Besides the transaction costs, this prevents and relieves unnecessary congestion on the blockchain. 💩
Learn more about how SWAP and other accounting protocols work by readingThe Book of Swarm .
Bee contains a rich set of features to enable you to query the current accounting state of your node. First, let's query our node's current balance by sending a POST request to the balances endpoint.
It is also possible to examine your per-peer balances.
In Swarm, these per-peer balances represent trustful agreements between nodes. Tokens only actually change hands when a node settles a cheque. This can either be triggered manually or when a certain threshold is reached with a peer. In this case, a settlement takes place. You may view these using the settlements endpoint.
More info can be found by using the chequebook API.
More information about the current received or sent cheques can also be found using the chequebook api.
As our node's participation in the network increases, we will begin to see more and more of these balances arriving. In the case that we have received a settlement from another peer, we can ask our node to perform the relevant transactions on the blockchain, and cash our earnings out.
To do this, we simply POST the relevant peer's address to the
You may check the status of your transaction using the xDAI Blockscout.
Finally, we can now see the status of the cashout transaction by sending a GET request to the same URL.
Success, we earned our first xBZZ! 🐝
Now we have earned tokens, to withdraw our xBZZ from the chequebook contract back into our node's own wallet, we simply POST a request to the chequebook withdraw endpoint.
And conversely, if we have used more services than we have provided, we may deposit extra xBZZ into the chequebook contract by sending a POST request to the deposit endpoint.
You may then use Blockscout to track your transaction and make sure it completed successfully.
#Managing uncashed cheques
For the Bee process, the final step of earning xBZZ is cashing a cheque. It is worth noting that a cheque is not yet actual xBZZ. In Bee, a cheque, just like a real cheque, is a promise to hand over money upon request. In real life, you would present the cheque to a bank. In swarm life, we present the cheque to a smart-contract.
Holding on to a swap-cheque is risky; it is possible that the owner of the chequebook has issued cheques worth more xBZZ than is contained in their chequebook contract. For this reason, it is important to cash out your cheques every so often.
With the set of API endpoints, as offered by Bee, it is possible to develop a script that fully manages the uncashed cheques for you. As an example, we offer you a very basic script, where you can manually cash out all cheques with a worth above a certain value. To use the script:
- Download and save the script:
- Make the file executable:
- List all uncashed cheques and cash out your cheques above a certain value:
If running ./cashout.sh returns nothing, you currently have no uncashed cheques.
Cashout all cheques:./cashout.sh cashout-all
Are you a Windows-user who is willing to help us? We are currently missing a simple cashout script for Windows. Please see the issue.
You can find the officially deployed smart-contract by the Swarm team in the swap-swear-and-swindle repository.