IPFS Workshop

An introduction to IPFS via the Desktop application.

Ideal for those new to IPFS.

Used in conjunction with the workshop slides


Before we begin:

Install IPFS Desktop

Now is the time to get IPFS Desktop! Instructions are available for Linux, Mac and Windows:

https://docs.ipfs.io/install/ipfs-desktop

Optional: Sign up for a pinning service

This is a cloud based IPFS node you can “pin” IPFS content on that will be available when your machine(s) are offline to teh rest of the IPFS network. Many exist! Here are a few:


Import and Serve a File via a Local IPFS Node

Let’s all use the same file to start:

The dApp Course Logo:


Right Click and download (“save link as…”) the image above, so we can play together!


Open IPFS Desktop and Import Files to your Node

Navigate to the “Files tab” and hit “+Import” and select the blockchain-at-berkeley.png file we just downloaded.


After you import…


You should see the file has a funny subtitle starting with Qm... - This is the CID of the file! Let’s take a deeper look at this file by inspecting it


Here we can see that this file is very small (81 KB) and thus all the data for it can be contained in just one chunk! Our Object has all the Buffer data it needs to reconstruct the file directly.



View Your file on Your Node’s Gateway

Now that your node has a copy of this file, we can view it via our local IPFS gateway - this is a HTTP server for IPFS. So we can use this webpage to interact with IPFS!

IPFS-desktop will, by default, bind the gateway to http://localhost:8080/ on our local machine. We can query IPFS content by CID through the desktop interface


Notice the URL (one of two versions, both are the same with different encodings of the CID):

This tells us that we are in fact looking up via our local machine (127.0.0.1 or localhost) and querying for data with a given IPFS CID of the preferred, newer format: http://<YOUR-CIDv1-HERE>.localhost:8080/


Ask Another Peer to Retrieve Your File

We can ask another IPFS node out on the wild web if they can see it! There are many public IPFS gateways that our fine friends host, and can be found here.

Let’s see what we find if we ask the https://ipfs.io gateway to retrieve our file’s CID. In much the same way, we just need to specify the right CID to retrieve:

Sweet! The file is found by the ipfs.io and dweb.link nodes via different encodings and different methods!! This confirms that not _just our local node knows about this file - our peers can get it too!! And in a various of ways.

Notice we didn’t upload this file anywhere! The IPFS network was able to retrieve it from OUR NODE!!!

!!! This is an important note:

So by following along here - you just advertized your node (by your peer ID) to other nodes you are connected to that you have and will share this data … if they ask nicely ;)


Peer Connections and Data Sharing

What?! You mean to say that I already am sharing this data with many different people all over the world from my node? 1

YES

You can see a list of the peers that you are directly connected to on the Peers tab:


Without going into the weeds on the details of how your node goes about sharing and finding data on the IPFS network (but you totally can here after the workshop) we experiment with asking your peers for some data directly.

We don’t need for a gateway (a single node out there somewhere) to gather all the chucks we need for some data - we can ask our peers for them!


Request content via CID

On any IPFS Desktop tab, at the top, you will see a search bar. Go ahead an put this CID into it:

Qmdgqdddt3F2uszEaE7zph7kXbwHX3iTDCWeQjdtNGnQgz

You will likely need to download this file if no preview is available. Note the proper extension for the file is .jpeg (it may not come with one or the wrong .txt extension, so add/change it if so)

What do ya see when you open this file???

NOTICE: No DNS or HTTP required! This was found directly on the IPFS network! The CID was all we needed - not a URL!

This fine photo is from a set of Apollo program photos and happens to be famous - you seen it before? This is one of many that are available on IPFS!

Wouldn’t it be awesome if you could browse a website album of all these on IPFS?2

YOU CAN!


Browse IPFS Static Website content

Static Websites are, as the name implies, consisting of unchaining data. There is no need for a backend server somewhere that must construct some data dynamically every time we want to view or use a web application.

Static sites are just a set of HTML, CSS, and JS files… so once created, we can host static sites on IPFS!!

To see this in action, the let’s checkout a static web album with our IPFS Desktop app open (so our node is running), click here:

Apollo Photo Archive

Notice the URL… its local!


So… our node behind the scenes looked up a CID and from this was able to construct the site… locally. Our peers delivered the content, and now we can browse the site… even offline (if we pin the site to our node) and will share the site’s content with any peers that ask for it!

By using and IPFS node to pin static websites, you are acting as a server for some or all of the content for the site on IPFS!

So what if I wanna publish an IPFS website and have others help share it and keep it alive… even when my node is offline?

Back to the workshop slides for more resources and how to do this!


Footnotes

  1. By default, yes. Only if you pin this data (file upload does this automatically). But this data will only be shared if other peers know the CIDs for content you hold and request it. And only if your machine is on a network that can connect out to other peers - and many firewalls and NATs don’t always play nice with this. 

  2. Here is the same photo in the Apollo archive album: http://127.0.0.1:8080/ipfs/QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D/albums/QXBvbGxvIDEwIE1hZ2F6aW5lIDM1L1U=/21328560323_6b33f5d4c3_o.jpg