How to Build an NFT IPFS Wallet for Your Collection

Using a Raspberry Pi, IPFS, and Pinata

Pinata
Pinata
11 min readNov 3, 2020

--

The following blog was written by @OficinasTK for Pinata. Check out Oficinas TK’s great crypto work on Async, Rarible, SuperRare, and KnownOrigin.

Hi! My name is Oficinas TK, I am a visual artist and collector. Have you ever wanted to create your own “IPFS Wallet” for your NFT collection? Well, I did!

Awhile back, I decided that I would like better control over my crypto art collection by “repinning” the NFT files from the pieces in the TCBA Collection. By repinning these files, I would be controlling my art collection in a way that was maintained and secured by me, regardless of the NFT platforms they came from.

In this blog, I will take you through the step-by-step process of how I created an IPFS wallet for my collection using a Raspberry Pi, IPFS, and Pinata.

Raspberry Pi Setup

Raspberry Pi’s have many flavors you can choose from. I went with the small and wonderful model Zero W because it’s cheap and it has onboard WiFi. In addition to the Raspberry Pi, you will need to get an a SD Card to install the Operating System and IPFS cluster.

For my Raspberry Pi, I set up a headless environment. This means that I haven’t used an external screen or display throughout the configuration. Because of this, we need to take a few additional steps like setting up the WiFi network and having VNC Server running on it. This is how we are going to connect to our Raspberry Pi’s IPFS cluster and operate it. There are other methods to connect and talk to your Raspberry Pi like via SSH, for example, but I believe this one is the simplest for beginners.

If you already have a Raspberry Pi with Raspbian installed, you may skip these steps ;)

Setup Raspbian

To get the Raspbian (Raspberry’s OS) image burned to the SD card, I chose Pi Bakery, a small and free software that allows you to build your own configuration by adding the relevant blocks. You can download it at https://www.pibakery.org/, and it’s available for Windows, Mac and as source if you would like to compile your own.

As you can see from the image above, I selected ‘Setup Wifi’. You will have to manually add your network id and WiFi password, disable the onboard Audio (not using it), and enable VNC Server at boot. Shutdown instructions are optional. If you use shutdown instructions, make sure it’s only on the ‘On First Boot’ block, otherwise, your Raspberry will be shutting down every time it boots.

After you drag your relevant blocks and build a configuration file, burn it to the SD card. This will take a bit as it’s burning a 1.5Gb image, be patient. When it’s done, insert the SD card on your Raspberry Pi and boot it up!

On your computer, install Real VNC (https://www.realvnc.com/) or a similar VNC client. After this, you should scan your network (‘arp -a’ command on Windows, or ‘nmap’ on Linux) to find out the IP address of your Raspberry Pi. Mine was on 192.168.8.106 so I inserted that in the VNC Viewer and connected.

There will be a prompt for user and password. The default user is ‘pi’ and password ‘raspberry’. Insert those and you should see the desktop of your Raspberry magically appear before you. It is highly advisable to change the default user and password.

Instal IPFS

First, let’s open up the terminal. Don’t worry, you just need to copy/ paste the commands and follow my instructions carefully. If you do, you’ll have your IPFS cluster running in a few minutes!

We will be using the following repository: https://github.com/lanzafame/ipfs-cluster-rpi.

The creator defines it as ‘a bare bones IPFS installer for the Raspberry Pi and other ARM-based devices’.

The first step is to open up the command line on our Raspberry Pi and type in:

git clone https://github.com/lanzafame/ipfs-cluster-rpi

This won’t take much time. It’s going to create a folder called ‘ipfs-cluster-rpi’ on your home directory and download the repository to it.

When it finishes type in:

cd ipfs-cluster-rpi

And, when inside that directory, type in:

./install

Wait for a bit…and it’s done. To make sure your IPFS cluster is well and running, you can type:

ipfs version

It should retrieve your current version (0.7.0 at the time of writing). Congratulations! You’re running an IPFS cluster on a Raspberry Pi. That’s something!

You can also try:

ipfs swarm peers

You should see a list of IP addresses like this one; these are other nodes on the network which means your Raspberry Pi connected successfully.

Find IPFS Hashes

So, what should we do with it? Well, I implemented this solution to ensure that the pieces I collected for the TCBA Collection, which is comprised of NFTs minted on the ethereum blockchain, would remain available online or offline to display however I wish.

A lot of NFT platforms, I’ll focus on KnownOrigin and the SuperRare Team in this post as I am an artist and collector that uses their platforms, already help us a lot by uploading the images or videos to IPFS when the NFT is created. By uploading to IPFS, the platforms have created a secure hash that they can then attach to the ERC-721 token. What’s great about IPFS hashes is that they are unique to each individual file. This ensures that the files haven’t been changed. If a file was ever changed, the IPFS hash wouldn’t match. You can learn more about NFTs and IPFS in the video below.

Beyond securing the file, IPFS hashes allow us to do two main things. First, IPFS hashes allow us to duplicate them to our own IPFS cluster and pin it. By doing this, we ensure better discoverability and availability of the files. The commands for this process are shared a bit further down. Second, IPFS hashes allow us to download the file attached to the hash. This allows us to easily access the collection of our own images and videos by digging into the info on the tokens.

Finding the IPFS Hash of an NFT

I’ll show you two ways of getting the relevant IPFS hash info from your NFT. First, I will show you how to find the NFT IPFS hash using one of my pieces on SuperRare. Then, I will show you how to find another NFT IPFS hash on KnowOrigin.

https://superrare.co/artwork-v2/ii---the-high-priestess-(ur-venus)-12295

If you follow the above link, you’ll go to the piece page that displays some info about it. Clicking on the image will open a pop-up. By right-clicking the image and clicking “Open Image in New Tab”, you’ll have a link that references the hash of this image. Tada! See below.

https://ipfs.pixura.io/ipfs/QmbiEPTJZ4nbdTCQxzwQgmahgoUt9qXwWuRvkm9XWfG46y/UrVenus.gif

SuperRare has it’s own IPFS node and pins the content there. But, since it’s on IPFS you can also see it following this link:

https://ipfs.io/ipfs/QmbiEPTJZ4nbdTCQxzwQgmahgoUt9qXwWuRvkm9XWfG46y/UrVenus.gif

Because you now know the IPFS hash, you can broadcast and download the file! Now, let’s get back to our Raspberry Pi and try some commands out.

Let’s download the collaboration I did with Gisel Florez. It’s OK with me, it’s for educational purposes and I’m sure you will not try to sell this image as your own ;)

To make a copy on your repository, make sure you are inside the folder where you want to keep the images. On the command line, input the following:

ipfs cat QmbiEPTJZ4nbdTCQxzwQgmahgoUt9qXwWuRvkm9XWfG46y/UrVenus.gif > NameItSomething

The above should start the transfer and you should see a progress bar like this one if the file is big:

The ipfs cat command alone would start the transfer of the hash. But, it wouldn’t wrap it as a file. Rather, it would show it as a stream on your console. In order to make a file that you can read, you’ll have to add the > NameOfFile at the end. In the above example, I saved the file named UrVenus.gif as a new file called otkxgisellx (you don’t have to worry about file extension as it will be appended automatically.)

Now, let us say you want to pin this file. Pinning a file signals its importance so it doesn’t get deleted from your IPFS nodes cache and remains available to the IPFS network. This is when we use ipfs add pin command. Try the following on your Raspberry’s command line:

ipfs pin add QmbiEPTJZ4nbdTCQxzwQgmahgoUt9qXwWuRvkm9XWfG46y/UrVenus.gif

Your node will now search the IPFS network and attempt to find the hash QmbiEPTJZ4nbdTCQxzwQgmahgoUt9qXwWuRvkm9XWfG46y. Once it’s been found on another node, it will retrieve that content and pin a copy of it locally.

After it’s pinned — and big files will take a while — you should get a response like pinned QmbiEPTJZ4nbdTCQxzwQgmahgoUt9qXwWuRvkm9XWfG46y/UrVenus.gif recursively

Now we know how to pin and to get files from hashes! So, let’s try it with something on KnowOrigin as well. KnownOrigin has a different way of getting your hash. They keep that info inside the token info. This means you can’t just open the image in another window this time :)

The case study piece: https://knownorigin.io/gallery/125900

You can see that there are some tabs on the right, and inside the ‘Info’ one you can see a link at the bottom that says ‘IPFS HOSTED’, click it and you’ll be sent to some of the token info that’s also stored on IPFS. You can see all sorts of cool attributes like the name of the piece, who made it, etc, and the ‘image’ attribute shows us the file hash:

“image”:”https://ipfs.infura.io/ipfs/QmcJMec8f2fx3B1hNTAZMdWj9JciEYqWmmFTmx895hW3pa/asset.png"

As a reminder, in the example above, “QmcJMec8f2fx3B1hNTAZMdWj9JciEYqWmmFTmx895hW3pa” is our hash.

Let’s get back to our Raspberry Pi and either pin it or download it using the ipfs pin add or the ipfs cat {hash} > filename commands.

As you can see, there are two files in our folder ‘Raspberry IPFS Node’, one from SuperRare and the other one from KnownOrigin.

If you get your NFT’s from popular platforms, it’s likely you can access the hash info pretty easily. Although, that’s not necessarily always the case. Sometimes, you’ll have to dig into https://etherscan.io/ and search inside the token for the info. Today, I’m not addressing these deeper methods because they are probably reserved to a more advanced type of user and we’re keeping the focus on IPFS.

Add Your Own Files

You can also easily add your own files using the ipfs add filename command. I uploaded a text file with the words ‘hello IPFS’ and, if you use the cat hash command without adding the file encoding > filename part, you can actually read the text on your command line.

If interested, I would recommend you to have a look at the official documentation about IPFS at their documentation page https://docs.ipfs.io/ as it has a lot of useful information on more advanced concepts and usage beyond this tutuorial.

Repin With Pinata

We now know how to add files, repin hashes, and add them to our repositories using our tiny Raspberry Pi Zero W. By using a Raspberry Pi, you ensure that you are in control of your NFT files at all times. However, Raspberry Pis aren’t the fastest or most stable way to repin your files. This is why many platforms use pinning platforms like Pinata. By ‘repinning’ the content on bigger and faster servers, they can ensure that our files are found faster and more reliably than from our Raspberry Pi to display.

Let’s have a look at Pinata.cloud and see how easy it is to use. Also, Pinata has a free tier for you to experiment with. After you have registered for Pinata, you’ll go directly to the ‘PINATA UPLOAD’ tab

You’ll see three tabs named ‘Upload File’, ‘Upload Directory’ and ‘Pin By Hash’. These are pretty self-explanatory. ‘Upload File’ allows you to upload a file. ‘Upload Directory’ allows you to upload a folder with all of it’s contents. And, ‘Pin By Hash’ allows you to add a hash directly.

In this example, I’m pinning the hash from my piece ‘Nameless Idol’ using the ‘Pin By Hash’ feature. To do so, simply copy and paste the hash into the field provided. Then, add the name, author and date in the description.

Now click “Pin” and Pinata will start looking for your content asynchronously until it finds it. Once Pinata is able to find your content it will grab it and pin it to the Pinata network of IPFS nodes. When pinning by hash, it’s super important that your content is discoverable by Pinata. This means it needs to exist on another easily discoverable node on the network. Examples of such nodes are those hosted by NFT platforms or the one you just set up on your Raspberry Pi. In the case of your Raspberry Pi, if Pinata is having a hard time finding your content, you may want to make sure your node is properly connecting to the rest of the IPFS network and isn’t behind any firewalls.

Once the file is added to the IPFS network, your pinned file should appear in the ‘Pin Explorer’. If you want, you can add your entire collection via ‘Pin By Hash’ or any of the other methods. By doing so, you will have all of your NFT files replicated on both your Raspberry Pi and on Pinata, ensuring you are in complete control of your NFT files. By using Pinata’s ‘Pin Explorer’, you will be able to better manage your pieces when the collection grows to a list of hundreds of hashes :)

Now, you have an IPFS Wallet on your Raspberry Pi containing all of your files from the NFT pieces you own. You can now connect it to an HDMI display ;)

In addition, your NFT files are also maintained on Pinata for fast retrieval and easy management of the files. You can easily use that hash info to build your own HTML webpage and display those images to share with your friends, a bit like I did with the TCBA Collection.

There are many possible uses for IPFS and I hope that this tutorial gave you some inspiration to order a Raspberry Pi (not sponsored by them OK?) to install an IPFS node and start pinning!

--

--