Deep Dive on Filecoin & IPFS use cases in the Solana ecosystem

  • What are Filecoin and IPFS, and what problems it's solving in the blockchain ecosystem?
  • Use cases
    – Using IPFS to store NFTs and metadata of Candy Machine V2
    – Using the various IPFS libraries for storage in your dapps
    – Deploying and hosting dapps on IPFS
  • Awesome Developer Tools
    – Pinata
    – Fleek
    – Web3.Storage
    – NFT.Storage

Filecoin and IPFS

Protocol Labs is the Research and Development Lab which proposed the whitepaper of IPFS back in 2014, and then, later on, Filecoin launched its Mainnet in 2020. Currently Protocol Labs, Filecoin and IPFS exist as different organizations.

Interplanetary File System (IPFS)

IPFS is a distributed system for storing and accessing files, websites, applications, and data. The core concept is to have a distributed storage system rather than a decentralized one to make it better. Considering even if we shift to multiple planets, a distributed storage network will help in getting better access to our files and folders.

Filecoin

Filecoin is a peer-to-peer network that allows anyone to store and retrieve data on the internet. Built-in economic incentives ensure that files are stored and retrieved reliably and continuously for however long a user specifies.
Filecoin includes a blockchain and native cryptocurrency (FIL).

Use cases

Using IPFS in Candy Machine V2

If you are a Solana Buildoor, you might already know what a Candy Machine is. If you don’t, Metaplex has created this easy to setup NFT Distribution program called Candy Machine.

{
"price": 1.0,
"number": 10,
"gatekeeper": null,
"solTreasuryAccount": "<YOUR WALLET ADDRESS>",
"splTokenAccount": null,
"splToken": null,
"goLiveDate": "25 Dec 2021 00:00:00 GMT",
"endSettings": null,
"whitelistMintSettings": null,
"hiddenSettings": null,
"storage": "ipfs",
"ipfsInfuraProjectId": <ADD_PROJECT_ID>,
"ipfsInfuraSecret": <ADD_SECRET_KEY>,

"nftStorageKey": null,
"awsS3Bucket": null,
"noRetainAuthority": false,
"noMutable": false
}

IPFS Libraries for your Dapps

You can’t store larger files in the smart contract itself as it will become quite expensive and will be a tedious job to perform, thus you can simply upload the larger files on IPFS and then store the CID in the smart contract.

const node = await IPFS.create()const data = 'Hello, Buildooor'const results = node.add(data)for await (const { cid } of results) {
// CID (Content IDentifier) uniquely addresses the data
// and can be used to get it again.
console.log(cid.toString())
}
const node = await IPFS.create()const stream = node.cat('QmQHXWBEM4xGySEcxf7MdaeKb453zAvkF8oRXRVQ9tqN9E')
let data = ''
for await (const chunk of stream) {
// chunks of data are returned as a Buffer, convert it to string
data += chunk.toString()
}
console.log(data)

Deploying and Hosting dapps on IPFS

After creating your fancy web app in any of the tech stacks like reactjs, nextjs, vue etc you can deploy and host the app on IPFS using Fleek. Fleek is pretty much similar to Vercel/Netlify, where you just connect your Github and it builds and deploys the project.

  1. Sign up on https://fleek.co/
  2. Click on Add New Site on the top right.

Awesome Developer Tools

There are a lot of Developer Tools which make life easier for the glass chewers to integrate IPFS and Filecoin. Let’s check out what functionality they provide and how to use them.

Pinata

Pinata is this easy to use tool which helps in pinning files and folders on IPFS. You can use it to store NFT Media, or any other files you want to store on IPFS. It has a simple UI as well as APIs to integrate it into your dapp.

  1. Go to their website https://www.pinata.cloud/

Fleek

As explained earlier in the article, you can use Fleek to deploy your web apps on IPFS. Fleek has more services to provide. Space Daemon packages together IPFS, Textile Threads/Buckets, and Textile Powergate (Filecoin*) into one easy to install background service. Space is the next evolution of the Cloud, where users can interact with apps fully private, p2p, and control their own data.

  • Fully Private file upload via encrypted textile buckets.
  • Peer to Peer file sharing selectively with other people and/or within teams.
  • Identity solution to enable users to be anywhere from fully anonymous to having as many identity associations as they want.
  • More….

Web3.Storage

It's another tool which provides you with an API token through which you can upload data on IPFS. The instructions are easy to follow and are well documented here.

import { Web3Storage } from 'web3.storage';

// Construct with token and endpoint
const client = new Web3Storage({ token: apiToken });

NFT.Storage

NFT.Storage is a side product of Web3.Storage specifically for the NFTs Metadata.

Conclusion

In this complete article, we went through multiple ways how IPFS and Filecoin can be integrated into the Solana Ecosystem. Thanks to all the awesome developer tools which make things easier for the developers. The libraries and their documentation make glass chewing easy.

Resources to study further

References

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harsh Ghodkar

Harsh Ghodkar

Coding Enthusiast | Machine Learning | Competitive Coder | Data Analyst | Full time Transponster