Storing data on the blockchain

So I’m looking into developing an app on Solana.
The questions I have are basically a series of questions based on what is possible.

What I’ve learned through some tutorials is that it is possible to store some data on the blockchain. And from what I’ve seen so far, the tutorials all show the ability to store small amounts of data. Like incrementing a number. However I want to store a JSON object. (For instance users activity as a JSON object with many child elements like a tree of data). I haven’t been able to find any info on if there is a cap size I am allowed to store.

Depending on if this is even possible or not, my next question would be, can this data be stored and viewed in Solscan or Explorer as plain JSON format, or will it need to be encrypted?

There is a 10MB cap I believe on the size of an account, but the bigger issue is not that cap size, but that you must pay for rent in order to persist the data on the chain, and rent on Solana is expensive.

For instance, 200kb of data cost 1.4 SOL to store on the chain and ensure that it will not be deleted.

If you need to store a lot of data then you probably need to store the data off-chain, in something like IPFS, and then store the unique content ID for that IPFS data on the blockchain. The unique content ID has a fixed size of 32 ( if I remember correctly ) bytes and will not cost an excessive amount to store on chain.

The issue is that now that your data is stored on IPFS, somebody has to choose to pin that data to make sure that it isn’t deleted off of the IPFS network.

If you did store the data directly on the chain, I believe Solscan has the option to display string data as readable strings.

Still, if you were going to store that data on the chain, you would probably want to store it in a binary encoding to save space, because JSON takes up more bytes than a binary encoding, and you wouldn’t want to waste a single byte when you are paying so much to store it on the chain.


So, in summary, storing lots of data on the blockchain isn’t the best option usually. You usually need an external database to store the data. IPFS is a cool option because an IPFS content ID uniquely identifies content and makes sure that it hasn’t been modified. So even though you are storing you data off of the blockchain, you still get to use the blockchain’s security features to make sure it’s tamper-proof.

You dont’ have to use IPFS, though. Even a MongoDB database could work, and you would just store hashes of your MongoDB data on chain, similar to an IPFS content ID.

1 Like

Thank you again for the insight.
I’m learning a lot from you. Will definitely look into IPFS and see if this will be easy for me to implement.

I’m assuming this a monthly cost?

thanks for information about storing data on blockchain, i like to share my website about blockchain application development

I was wondering if there’s a cost calculator website to determine how much a data string stored indefinitely will cost.

There’s not a website that I know of, but you can use the Solana CLI:

# substitute 32 with the number of bytes long your string is
➜ solana rent 32
Rent per byte-year: 0.00000348 SOL
Rent per epoch: 0.000003048 SOL
Rent-exempt minimum: 0.0011136 SOL

The amount of SOL required to store the string indefinitely is the “Rent-exempt minimum”.

Perfect! Thanks again zicklag!

1 Like