IPFS Bootcamp
Tags: ipfs, tutorial, wax, blockchain
Published: 2023-08-03 03:25:24

## Introduction

Previously, we covered creating a simple contract that stored entries in a table of who owned a cat with a name. As we make more complicated and robust NFTs, we are going to want to associate images with our NFTs.

We could store images in the traditional manner of hosting the image via an HTTP accessible location, and then embed that HTTP link in the NFT table entry. But, if the webserver housing the image goes down, now the link is inaccessible and so is the image.

To decentralize our images for our NFTs, we are going to do a quick dive into IFPS.

## What is IPFS

We want our NFTs to live on the blockchain, but the images for the NFTs are typically too large to host on the blockchain in a cost efficient manner. What is done instead is that a reference to the image is stored on the blockchain instead. You may see some NFTs using HTTP URLs for their images, but as we all know from broken links on the web, these can suffer from [link-rot](https://en.wikipedia.org/wiki/Link_rot#:~:text=Link%20rot%20(also%20called%20link,address%20or%20becoming%20permanently%20unavailable.).

Instead we can use IPFS - InterPlanetary File System - to store and retrieve files. IPFS is a decentralized protocol where instead of relying on centralized servers, IPFS allows users to store and retrieve files by their content, using a unique Content ID (CID).

## Our Images

For the example NFT that we will implement in upcoming sections, we will need a few images: the collection image, and images for our NFTs. We are going to implement an example NFT called “BabyChicks”, so we will need an image for the egg, and images for each type of baby chick.

Collection image:

![BabyChick collection image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcls7e5gtihxoo9optyx.png)


Egg:

![Egg image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjor80m9baxw5gw89z4l.png)

Baby Chick Common:

![Common BabyChick](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qihe5c1v1pj971tf2fg2.png)


Baby Chick Rare:


![Rare BabyChick](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j63guhd2ymk1gmobcg8q.png)


Baby Chick Legendary:

![Legendary BabyChick](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6llmho5me429lw3egjiq.png)


## Uploading to IPFS

To get started with uploading and viewing IPFS files, we will use a GUI Desktop app. The one I will use is https://docs.ipfs.tech/install/ipfs-desktop/. Once installed, run the application.

Head on over to the Files tab. We will create a folder to group all of our images together:

![IPFS Files](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tso8hdmijq4uq7xdmqq0.png)


Next we upload all of our files


![IPFS Images](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fnh02wsegrejbgf06xo.png)


For each file, we also click the “Pin to local node” button, to ensure that our local node will always have a reference to the file.

The last thing I like to do to ensure that a public gateway picks up the IFPS file hash is to right click each image, go to “Inspect”, and then in this screen click “View on Public Gateway”:


![View on Public Gateway](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkr4m5v66tqashvxl6r7.png)


This helps the public gateways pick up on your new image.

## Referencing IPFS Files

You can reference these files one of two ways:


![Reference images](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uept0zl4ru8rbguatmcq.png)


When you right click any file, you will see a Share Link which by default will give you a link to using https://ipfs.io/ipfs as the IPFS public gateway.

Otherwise, you can share the CID of your file. When we define our NFTs, anytime an image string is expected, we will use our CIDs. 

## Dark Emblem Images

If you look at [Dark Emblem on AtomicHub](https://wax.atomichub.io/explorer/collection/wax-mainnet/darkemblemc1), you’ll notice we don’t use IPFS, and instead rely on traditional HTTP links for images. This is because in Dark Emblem, we generate a new, unique image every time a pack is unboxed and a Card NFT is minted.

When you go to implement your on NFT game, you’ll want to think about these decisions. There are pros and cons to each decision you make. In the case of Dark Emblem, we wanted to the simplicity of being able to mint new unique images based on random card traits that are generated on the blockchain. Your NFT may be simpler and easier to implement by pre-generating all the images and uploading to IPFS.

## Conclusion

In this last section, we went over what IPFS was, how to upload files to our local node, and get those file hashes to be discovered by a public gateway. We also went over the pros and cons of this approach when dealing with different types of NFT minting.

In the next section, we’ll start to look at AtomicHub and AtomicAssets in order to create NFTs that are part of a larger ecosystem on the WAX blockchain.

Next post: [ Introduction to AtomicAssets ](https://dev.to/idmontie/introduction-to-atomicassets-45mk)

## E-book

Get this entire WAX tutorial as an [e-book on Amazon](https://amzn.to/3ZjwaK7).

## Additional links

- Github: https://github.com/CapsuleCat/wax-nft-tutorial/tree/main/simplenft
- Documentation: https://docs.ipfs.tech/install/ipfs-desktop/
- Further reading: https://docs.ipfs.tech/concepts/
- Photo by [Li Zhang](https://unsplash.com/@sunx?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/photos/pWGhklLD6VA?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)