My children and their friend asked me if I could help them build an NFT collection.
A what? Yes, I am old enough that I was not up to speed on NFTs.
Step 1: Google “What is an NFT collection”.
Without going into detail on the background of an NFT, I saw two challenges.
Could I take a series of hand-drawn images (they used Procreate on an iPad) and build layered, mashup that combine them into unique characters and control the rarity of certain characteristics?
Could I then use Alteryx to summarize the rarities and build the metadata files that we would later push to IPFS?
As someone that is guilty of thinking about a challenge in the context of the tools I know, my first thought was “I bet I could do that in Alteryx.”
This article is a brief description of that process and yet another demonstration of how Alteryx can help non-coders solve unexpected challenges.
Challenge #1: Build an engine that can generate any number of combinations of traits (each of which are unique image files) to craft thousands of unique characters.
What did we need?
Artwork: Check, my children are incredible artists, and we had that part nailed from day 1.
The ability to combine images across multiple layers to build characters including the capacity to:
Randomize the effort, yet influence the rarity of certain unique features
The ability to summarize feature statistics across the collection
The capacity to generate JSON files that describe each NFT, which are used to show traits on the NFT Marketplace, Open Sea.
#2 Random Image Combination Engine:
This one required a little research. I was looking for a library that manipulated image files. I came across the Python library “Pillow” that perfectly addressed our needs. I could see that it was much more powerful than I needed but had the ability to overlay images controlling location, transparency, and other features. Pillow allowed me to combine the files, but I still needed the ability to randomize the combinations and influence the probability of certain traits (image files) appearing. “Randomize”? “Probability”? Alteryx community to the rescue. A quick search on the community and I was able to find the logic to randomly generate combinations and influence the probability of selection.
Time to get to work. My children started to generate the artwork. If you are not familiar with the NFT space, you start to get different files by doing something conceptually like this…
Before we were ready to build the mashups, we needed to generate the list of traits, the different variants for each trait, and then the file path for each of those versions. Once we had that file, we then needed to randomly generate the combinations of features. For this I wrapped the workflow concepts I found on the Alteryx community into a Macro. I built a workflow that would generate a random pattern of each trait, influenced by the rarity probability we assigned, for the number of NFTs we were creating. The randomizer macro looked something like….
Coming out of the workflow that wrapped this randomizing macro we had a row for each NFT we wanted to create. We had columns (fields) for each trait and the value in those fields was a path to the artwork for that feature. We were ready to build the NFTs.
Python to the rescue. I ended up feeding that data mentioned above into a Python object within an Alteryx workflow. That Python object parsed out the file names for each of the layers and then sequentially called and Image. Open and and Image. Paste function from the library. Once all of the layers where “pasted” into a single image, we called the “.Save” function to save the newly created NFT to disk.
This was one of those cases where you press Run, close your eyes and pray. I had File Explorer open to the output folder. It took 20 seconds to start, but after that I could see fully formed NFTs appearing one after the other. Incredible! 20 minutes later we had created 10,000 NFTs.
That workflow was more basic than I expected. It looked like…
#3 and #4 Meta Data and Stats:
From there, we took the file that had the random combination of traits and shaped the data a bit and output it to 10,000 JSON files that were named identically to the images. Each JSON file had the properties for that image and is used by Open Sea to tell viewers the different characteristics of the image as well as rarity. That workflow looks worse than it is…
We did it. We built an NFT collection from hand-crafted artwork that my children made using Alteryx!
For those that are interested in the NFT space and doing this yourself, I would encourage you to check out YouTube videos on the process. There are other engines, typically Java Script, that can help. While we did not even entertain these, they look robust. I did notice however, that once our engine was complete, we had the ability to add logic to our combination engine which I had not seen in anything on YouTube. Rules like
Don’t show tattoos if the shirt has long sleeves.
Don’t mix headphones with certain hats.
Alteryx’s logic actually allowed us, my children actually, to have more artistic freedom than a completely generic engine from the web.
That was our Alteryx NFT journey. Hope there is something in here that can help out!