When we try to build a DApp, we can deploy our code on the blockchain. Also, we can store all the data on a blockchain to made data decentralize. However, most blockchain platforms are not meant to handle massive amounts of data.
For Ethereum, the full node is around 2TB now. Imagine we store all our videos on the Ethereum, it could cost a lot of space on Ethereum blockchain.
If you have ever deployed your program on AWS, you may have the experience to deploy your code on the EC2 VM. When you store all your data on the same VM, you may find your disc get full very quickly. It cost you a lot for your AWS fee. What most developers will do is store data in another service called S3.
Are there any decentralized data system? The answer is yes. The most famous one is the InterPlanetary File System (IPFS) Its an improvement of BitTorrent.
There’s a book that tell more ideas about the role of IPFS. You can get it on Amazon.
Now, let us have hand-on experience of IPFS. What will be in this example, we will upload our website LearnThings.Online on the IPFS, and visit it via HTTP.
To prepare, First, download our website. You can do it in the console by
“wget –mirror –convert-links –adjust-extension –page-requisites –no-parent learnthings.online”
You can see a folder called “learnthings.online”
Second, install IPFS on your computer. https://docs.ipfs.io/guides/guides/install/
If you install it successfully, you can start the daemon by
We can see Daemon is ready. Now open another console window. We add the folder learnthings.online to IPFS by
ipfs add -r learnthings.online
We can see, each files & folders will get their own CID
The folder “learnthings.online” have CID “QmZg48VEAjMHSTweE8FnvEcuDbogRQBPVR5vsTrMnBiMkV”
And we can see the file on the browser via
We can see, it shows on our localhost. Can other people see this? Actually, there are some IPFS gateways to help people to check the file. See https://ipfs.github.io/public-gateway-checker
We use dwb.link to check the origin file.
We can check the file via http://dweb.link/ipfs/QmZg48VEAjMHSTweE8FnvEcuDbogRQBPVR5vsTrMnBiMkV (It take time when we first load it.)
There’s one problem arise. How can we update the file? It comes into the tool IPNS.
Now, generate an IPNS link.
We know we can visit our file through We can check the file via http://dweb.link/ipfs/QmZg48VEAjMHSTweE8FnvEcuDbogRQBPVR5vsTrMnBiMkV
So, what’s IPNS link? What it means “Published to QmedPEKLwDxZo6TQ9BXWVAAxFPxWA9AACdu1PmX6PX36d”?
Let’s visit http://dweb.link/ipns/QmedPEKLwDxZo6TQ9BXWVAAxFPxWA9AACdu1PmX6PX36d
We can see the same thing. Actually, the CID “QmZg48VEAjMHSTweE8FnvEcuDbogRQBPVR5vsTrMnBiMkV” will change when we update the file.
Let’s see, what will happen if we change the file about.html?
We found the CID for about.html & learnthings.online changed. And other files are the same as above.
Now, get the IPNS Link again, we found it get the same IPNS. It means we can get the same link with IPNS even we update the file.
Till now, we know how to put files on IPFS, check files through HTTP, update files. But there are some important questions. Will the file always remain exist on the IPFS network? The answer is no, there’s no incentive for people to help you to store files. Protocol Labs, who build IPFS, try to build a blockchain system to implement the IPFS called Filecoin. The test-net of Filecoin is online now.
There are some materials you can check if you like to go deep.