Exploring the IPFS Protocol and its Integration with NFTs
The IPFS protocol finds application in the realm of NFTs for storing not only metadata associated with the NFT but also the images themselves. To illustrate this in a practical context, let’s consider a tangible example of an NFT, such as the card featuring football player Messi in the fantasy game Sorare
If we check the section token details we can find these informations:
The Token ID directs us to Etherscan, providing access to the contract’s details and its source code. Being an NFT, it adheres to the ERC-721 standard.
Then we can see that the metadata and the picture related to the NFT are hosted on IPFS and from the link we can uderstand that both have been hosted on Pinata Cloud that offers a service of IPFS gateway.
The picture hosted on IPFS was the one showed before, while the metadata associated to the NFT are these:
{
"description": "Sorare Football Fantasy NFT collection",
"image": "ipfs://QmNdeKuZZYn9kswVc9e5AP5F7HJNJWpeAsLsvzpK5Npajg",
"attributes": [
{
"trait_type": "edition",
"value": "classic"
},
{
"trait_type": "player_age",
"value": 35
},
{
"trait_type": "player_birth_date",
"value": "1987-06-24"
},
{
"trait_type": "player_blockchain_id",
"value": "25231422346618897466161184991066014710242912075232564827261144631247649555194"
},
{
"trait_type": "player_blockchain_name",
"value": "Lionel Andrés Messi Cuccittini"
},
{
"trait_type": "player_country",
"value": "ar"
},
{
"trait_type": "player_kit",
"value": "home"
},
{
"trait_type": "player_name",
"value": "Lionel Messi"
},
{
"trait_type": "player_position",
"value": "forward"
},
{
"trait_type": "player_shirt_number",
"value": 10
},
{
"trait_type": "scarcity",
"value": "rare"
},
{
"trait_type": "season",
"value": 2023
},
{
"trait_type": "serial_number",
"value": 50
},
{
"trait_type": "team_blockchain_id",
"value": 72
},
{
"trait_type": "team_city",
"value": "Miami, Florida"
},
{
"trait_type": "team_country",
"value": "us"
},
{
"trait_type": "team_international",
"value": false
},
{
"trait_type": "team_name",
"value": "Inter Miami"
},
{
"trait_type": "team_year_founded",
"value": "2018"
}
]
}
The primary reason behind storing NFT images and metadata on the IPFS protocol is its cost-effectiveness compared to blockchain storage. Given the crucial role played by the IPFS protocol in hosting vital information about our NFTs, delving into its workings becomes essential.
Before we delve into the intricacies of the IPFS protocol, let’s explore the two predominant system architectures widely embraced globally: client-server and peer-to-peer.
Client-server vs peer-to-peer architectures
The inception of the client-server model traces back to ancient times, serving as a foundational structure. Within a client-server architecture, fundamental to the HTTP protocol, data is centralized on servers, with access determined through location-based addressing (IP).
In contrast, the peer-to-peer architecture distributes data across multiple computers or peers, constituting a decentralized storage network. This architectural paradigm emerged to meet the demand for transferring large volumes of data, particularly in audio or video formats, areas where HTTP was not originally designed to efficiently handle such magnitudes.
What is the IPFS protocol
IPFS stands for InterPlanetary File System and is a protocol and a peer-to-peer network for storing and sharing data in a distributed file system, where each file and all the blocks within it are identified by a unique fingerprint called cryptographic hash.
In fact each peace of content in IPFS is identified by a unique hash derived from its content, therefore the data is addressed by its hash (content addressing) rather than by its location (as in the HTTP protocol), such as an IP address (location addressing).
The three key responsibilities of the IPFS protocol are:
Representing and addressing data
Routing data
Transferring data
The peer-to-peer network is composed by multiple IPFS nodes, which are just applications executed on a physical machine.
IPFS enables users not just to receive but also to host content, resembling the approach used in BitTorrent. Unlike a centrally located server, IPFS is structured on a decentralized system of user-operators, each holding a segment of the entire data. This design establishes a robust system for file storage and sharing.