The web as we know it today is controlled by centralized servers and accessed by location-based addressing. With that comes potential issues in the chance that a server is hacked, or if it happens to crash. This would leave the user that is requesting the data with nothing but an error page. That’s where IPFS can be of assistance.
An Interplanetary File System (IPFS) is a peer-to-peer file-sharing system created by Protocol Labs. IPFS is used for storing and accessing files, websites, applications, and data. IPFS uses content-addressing to identify each file in a global namespace connecting all computing devices.
IPFS allows users to host and receive content in a decentralized manner via peer-to-peer file sharing. This means that user-operators hold a portion of the overall data which creates a strong system of file storage and sharing.
Any user in the network can serve a file simply by its content address, and other users in the network can locate and request that content from any person who has it using a distributed hash table (DHT).
So, rather than being location-based, IPFS addresses a file by its content. To identify certain content, IPFS uses a cryptographic hash of the content at that address, and the hash is unique to the content it came from. In reality, IPFS aims to create a single global network.
For example, if Alex and Nick publish a block of data with the same hash, the users downloading the content from Alex would exchange data with the ones downloading it from Nick.
Normally, when you put a URL into your browser, your computer asks another computer for that specific page you are requesting. However, that’s not the only way you can retrieve that page, rather, if there is a mirror of that page stored on IPFS you could use that.
Instead of asking a single computer for a page, your computer uses IPFS to ask several computers around the world to share the page with you. That means you can get the page you’re requesting from anyone around the world who also uses that page on IPFS, not just a single computer.
Keep in mind that when you use IPFS, you aren’t just downloading files from someone else, your computer also helps distribute them. This is true for any kind of file a computer might store, whether it be a web page, document, email, or database record.
Overall, there are four main components to IPFS, lets take a look at each one.
Distributed hash table (DHT)
A data hash table (DHT) is a data structure that implements a structure that can map keys to values. A DHT uses a hash function to compute an index—aka hash code—into numerous slots, from which the desired value can be located. This means data is spread across a network of computers and coordinated to enable efficient access and lookup between nodes.
The advantage of DHTs includes decentralization, fault tolerance, and scalability. DHTs can scale to accommodate a ton of nodes, and even if a node fails or leaves the network, the system will still function properly.
BitTorrent, a popular file-sharing system, is able to coordinate the transfer of data between countless nodes by relying on a data exchange protocol, but, it is limited to the torrent ecosystem.
That’s why IPFS implemented a more general version of this protocol called BitSwap, which operates as a marketplace for any kind of data.
Merkle DAG is a combination of Merkle Tree and a Directed Acyclic Graph (DAG). The Merkle Tree is responsible for ensuring that data blocks exchanged on p2p networks are correct, and not altered in any way.
The verification is done by organizing data blocks using cryptographic hash functions, which is a function that takes an input and calculates a unique alphanumeric hash that corresponds with that input. Ensuring that an input will result in a given hash is simple, but it’s very difficult to guess the input from a hash.
A DAG is a method of modeling topological information sequences with no cycles. A family tree is a basic representation of a DAG. A merkle DAG is essentially a data structure in which hashes are used to refer to data blocks and objects. The main principle of IPFS is modeling all data on a generalized merkle DAG.
Self-Certifying File System
A self-certifying file system (SFS) is a distributed file system that doesn’t need special permissions to exchange data. The data served to a user is simply authenticated by the file name, which is signed by the server. Meaning, you can securely access remote content with transparency of local storage.
The decentralization of IPFS
When it comes to decentralization and IPFS specifically, there is one main goal: make it possible to download one file from many locations that aren’t managed by one organization. Of course, this comes with many benefits including:
- Supports a strong internet. If someone decides to attack a specific web server you are using, or the server happens to crash, you can still retrieve those same web pages from others.
- Increases the difficulty to censor content. Since files on IPFS can come from numerous locations, it’s harder for anyone to censor content.
- May potentially speed up your request if you are far away from the server that is sending you the request. If you are able to retrieve your request from someone nearby opposed to someone who is further away, you can retrieve your request quicker.
I know. There are a lot of complex terms and technology when discussing IPFS, but the main point is that IPFS aims to change how networks of people and computers communicate. Web 2.0 is structured on ownership and access, meaning whoever owns the file is the same person that serves you the file.
With IPFS, however, the structure is based on possession and participation, meaning multiple people possess each others’ files, and by participating in consuming the file, you are also distributing the file.
Best practices for storing NFT data using IPFS
When it comes to storing an NFT’s metadata, the data is only as good as the server storing the data. That means if the server were to crash, you would lose all the associated metadata to your NFT.
What is NFT metadata? NFT metadata is the content and description of the content described in the contract that is stored on the blockchain.
Considering it is difficult to change an NFT’s metadata and where it’s stored, it’s a good idea to think about how the data for your NFT is stored.
IPFS allows users to store and retrieve content based on a CID (cryptographic hash). You can put IPFS CID into an NFT so that it references the data itself rather than a traditional HTTP link, which is likely to fail over time. This means as long as one copy of the CID exists on the IPFS network, it can be accessed.
The main reason to store your NFT’s metadata on IPFS isn’t to provide it with permanent storage, rather, it helps prevent the link rot that commonly occurs with HTTP links. However, it doesn’t completely solve where off-chain data is stored.
If you are considering storing or minting your NFT’s metadata on IPFS, some good options are NFT.Storage and Pinata.
To learn more about best practices for storing your NFT’s data using IPFS, go to docs.ipfs.io.
What can you do with IPFS?
With IPFS, you have the ability to do many things, such as:
- Desktop applications
- Share your files or sell copies of it
- Dead drop
- Collaborate on written documents
- Version control
- Connect event attendants
- Exchange messages
- Store assets
Althought this list is rather broad, you can learn the specific details by visiting docs.ipfs.io.
Ultimately, if IPFS is successful, it will provide a strong foundation for the future of the internet. The aim for the future of the web is to be transparent, secure, and distributed so that it’s not under the control of one main entity, and IPFS can help achieve this goal.
Portions of this page are reproduced from work created and shared by Protocol Labs and used according to terms described in the Creative Commons 3.0 Attribution License.