Module 6: Managing Postage Stamps

Provides an in-depth understanding of postage stamps in Swarm, how to purchase them using swarm-cli, and manage their usage. It also covers troubleshooting tips for common postage stamp issues.

To be able to upload data to the swarm network you have to purchase a postage stamp. Each stamp has an allocated space that can be used for data uploads. For example a postage stamp could have 16GB worth of data uploads.

The stamp ID in the swarm network is funded with BZZ/xBZZ. In our case because we are using a simulated swarm network we don't need to worry about funding the stamp.

For bee-factory a sample/test stamp ID is automatically produced.

To check our postage stamps or purchase one we need to setup swarm-cli.

1.0 Setup Swarm-CLI

  • You can install swarm-cli via:
npm install @ethersphere/swarm-cli
1.1 Purchase a stamp
  • You can purchase a stamp and set the amount with:
npx swarm-cli stamp buy --depth 20 --amount 100000000 Which will show an output: swarm-cli stamp buy --depth 20 --amount 100000000 Estimated cost: 0.010 BZZ Estimated capacity: 4.00 GB Estimated TTL: 5 hours 47 minutes 13 seconds Type: Mutable When a mutable stamp reaches full capacity, it still permits new content uploads. However, this comes with the caveat of overwriting previously uploaded content associated with the same stamp. ? Confirm the purchase Yes Stamp ID: 92be753d6e96d167b2fa7df0......6dbf46113ff3af7ca339131179670ba34e
  • For more information on which depth and amount to specify, check out the relevant section in the Bee documentation.

2.0 ENV Setup

  • Now that we have the postage ID we can enter it into our environment or Vercel Environment:
export BEESTAMP=INSERT YOUR STAMP HERE

  • In our setup we are using Vercel and we entered this into Vercel's environment configuration. Once we modified the configuration we redeployed via Vercel.

3.0 Known Issues

  • When the above Stamp ID was entered it did not work. So we ran the command below to show which Stamp ID was not being used:
swarm-cli stamp list --max-usage 0 --quiet --hide-usage

4.0 Postage Stamps Commands

  • List all postage stamps:
swarm-cli stamp list
  • Grab the first postage stamp:
swarm-cli stamp list --limit 1 --quiet --hide-usage
  • Grab the least used postage stamp:
swarm-cli stamp list --limit 1 --quiet --hide-usage --least-used
  • List all postage stamps with zero utilization:
swarm-cli stamp list --max-usage 0 --quiet --hide-usage
  • Sort postage stamps based on utilization (least utilized comes first):
swarm-cli stamp list --least-used --quiet

5.0 Swarm-CLI Status

  • We can use swarm-cli to see the status of our server:
swarm-cli status Bee API: http://localhost:1633 OK Debug API: http://localhost:1635 OK Version: 1.13.0-f1067884 Mode: full Topology Connected Peers: 4 Population: 4 Depth: 0 Wallet xBZZ: 99999999.9890948096 xDAI: 9.998946300382567846 Chequebook Available xBZZ: 0 Total xBZZ: 0 Staking Staked BZZ: 0 Redistribution Reward: 0 Has sufficient funds: true Fully synced: false Frozen: false Last selected round: undefined Last played round: 0 Last won round: 0 Minimum gas funds: undefined
  • This shows us that the API is working as well as other information which may be useful for development purposes.
We are ready to proceed with our dapp!

6.0 Check Data Uploads

  • We can check the status of our Postage Stamp ID with:
swarm-cli stamp list Stamp ID: ebbddee277ee4e48861241c05943......ce3340887a1d2b9606cde6e987173f Label: ==testingStamp== Usage: 2% Remaining Capacity: 15.75 GB TTL: unknown Expires: unknown
  • This shows us that the data is being uploaded.
6.1 Can We Delete Uploaded Data?
  • The immutable feature of Swarm prevents us from wiping the data that we have uploaded.

Questionnarie

You need to join society to be able to do this

- How do you setup swarm-cli?

- How do you delete files from the swarm network?