1 min read

Per item vs by weight

Let's say you've just walked into the laziest store in the world.

In this store, there are no price tags. Everything is either pay per item ($1 each) or pay by weight ($1 per pound).

The kicker is that you get to choose how you want to be charged.

If you're looking to buy a car, that per item price looks pretty attractive, but if you need to buy a thousand feathers, paying by weight makes more sense.

Still with me?

This is how you should think about data storage on blockchain. It will be expensive if you do it wrong.

"heavy items" are big files: images, videos, webpages, etc. You could store the whole thing on chain, but that's equivalent to paying by weight. Instead, store the file off chain in cheaper storage, and just store relevant metadata (link to file, hash of data, etc.) about the file on chain.

"light items" are those frequent actions/events/transactions that take place in your app. Each one is unique, but there's not a lot of data to store. Usually, you just want a record that it happened, which is effectively metadata to begin with. This type of data is appropriate to store on chain and pay by weight. Just be careful how much weight all these little items add up to. Design your dApps to avoid undue storage cost as more people use and enjoy your app.


P.S. It's all about scale. If you're just uploading one heavy file, it's not a big deal. If your app lets anyone upload as many heavy files as they want, you need to keep that data off chain.