Skip to content
David Hawig edited this page Jul 30, 2018 · 2 revisions

Why IPFS?

Storing big files permanent on the tangle is a problem since you usually end up doing a huge number of proof of works, which is quite inefficient and takes a lot of time. Instead, you just want to store a link to the file on the tangle and store the actual file with an off-tangle solution. The problem with this is that links always point to the same location, so you can not really decentralize the off-tangle solution and you will always break the previously uploaded links if you decide to switch your storage provider. That is where IPFS (InterPlanetary File System) helps. With IPFS the files don’t get a unique address which tells you where to find something, but rather they simply get a unique fingerprint called a cryptographic hash, which is similar to a unique name. This way you can simply share the unique fingerprint of a file on the tangle and can change your storage provider of the file whenever you want. Furthermore, it’s easy to decentralize the system since multiple parties can store your file with the same unique hash and you simply download from the closest provider of this file.

How to use IPFS in C#?

If you want to integrate IPFS in your application you have two options: You can either run the complete engine in your program (see https://github.com/richardschneider/net-ipfs-engine) or you can just connect with the API (see https://github.com/richardschneider/net-ipfs-api) to an IPFS node. Running the complete engine uses quite some resources since you basically become a server for other files as well. Furthermore, it probably makes only sense when your program is running 24/7. Otherwise, your files won’t be always available. That’s why I highly recommend using the API integration for mobile applications like Chiota. The only issue with using only the API is that most public IPFS nodes, which you can currently connect to, only allow you to use the gateway to store your content and this means that everything you upload will be removed again after a certain time.

For this reason, I set up an IPFS node where you can also access the “add” part of the API to store files permanently (called “pin files”): https://ipfsnode.de:5002/api/v0/add. As far as I know, there is currently only one other node which allows this for testing and this is https://ipfs.infura.io. Anyway, if you plan to use IPFS for a lot of or huge files please consider setting up your own IPFS node. The following tutorial is quite helpful for this: https://medium.com/textileio/tutorial-series-setting-up-an-ipfs-peer-4056e6c69612.

The only thing left to do is the actual integration in your code. Therefore you simply have to install the correct nuget and then can take a look at the IpfsHelper class in Chiota, which is quite easy to understand.

If you have any questions or need access to other parts of my API, feel free to reach out to me.