Interplanetary File System

A peer-to-peer hypermedia protocol

5 minute read

Required expertise level : Intermediate

Platform : Gnu/Linux | macOS | MS Windows | Android | BSD

While it’s basically built as a data storage and distribution protocol, makes the way it functions different than most current day web hosting and cloud functions today, where in most cases, websites are basically web applications which processes and renders on a server then send the resulted web pages to the user.

In IPFS case, there are no server nor processing capabilities, which mean that it’s only capable of serving static or semi-static web pages, essentially anything which depends on client-side rendering and processing. in this scenario, the browser gets to do most of job and IPFS just delivers raw files.

Installing IPFS

  • MS Windows

    • Install the CLI tool using Chocolatey windows package manager choco install ipfs
    • Install the Desktop app (GUI) Chocolatey choco install ipfs-desktop
    • Or download the installation file directly from IPFS website
  • Gnu/Linux

    • Download and run the installation script for the Command Line Interface - CLI - tool from IPFS website
    • Download and run the installation package for the Graphical User Interface - GUI - desktop app from GitHub
  • macOS

    • Install using Homebrew package manager. brew install ipfs
    • Download the Desktop app from GitHub

IPFS Desktop app

Adding your static mirror to IPFS

  • After following IPFS guides on how to get the application on your machine running, confirm
❯ ipfs --version
ipfs version 0.6.0
  • Using your termianl, go to your static mirror directory.
  • Run ipfs add -Q --recursive --progress mystaticmirror

  • Now, we can try to access our mirror using IPFS and the hash of the root directory.

There are two ways of accessing files on IPFS

  • using the local client (peer-to-peer)
  • Install IPFS Companion browser extension and make sur IPFS is running on you machine.
  • When you enable the extension, it detects if your local IPFS daemon is running in the background and automatically rewrites any IPFS URL that contains a valid hash to be fetched using your local IPFS installation.

Updating a website on IPFS

As we mentioned earlier, IPFS depends on a hashing system to keep track of files, and since every file will create a unique hash, that means the final - root directory - hash will be different every time.

This situation presents a usability issue, as you will need somehow to share the new calculated hash with your audience every time you update your website, in order for them to be able to reach the most recent version of your website on IPFS.

Enters the Interplanetary Name System (IPNS)

Using a locally generated key on your machine, IPNS will create a static hash, which will be published to the Distributed hash table (DHT), this key can be linked to another hash and store it as value.

Think about it (IPNS) as a domain name generator, it gives you a random hash, and register it in a table and store the most recent hash of your files as a value, IPFS users will just need the static IPNS hash to access your website.

  • Generate a new IPFS key

ipfs key gen --type=rsa --size=2048 mystaticsite

The output will be your new IPNS address

  • Publish your IPNS address and link it with your mirror’s most recent hash.

ipfs name publish --key=mystaticsite [replace with your files most recent hash]

The output will confirmation for the linking between the IPNS address and the IPFS hash

  • We can confirm that your new IPNS address is alive either by accessing it using a gateway i.e. |[put your IPNS hash here] |, or enable IPFS Companion browser extension to be redirected automatically to your local gateway

Last modified September 20, 2020: fixes (548aeca)