In the beginning of 2021 NFTs became a massive hype. Their value skyrocketed and many people saw it as an investment opportunity. Now in 2024 most NFT collections are worthless and even the most famous and valuable ones have lost most of their value. Many people at the time knew it was a temporary hype and all the scams show that as well. I enjoyed making NFTs as I am always curious to learn about new technology, but never sold them.
The aim of this article it to capture the fun of using this new technology for creating NFTs without any consideration of their monetary value (because there is none). It is a fun technology which I hope gets adopted in different ways. Especially with AI now being able to generate very high quality pictures ‘art’, a combination between the two technologies can have interesting results. Go try it for yourself!
Step 1: Create layers
My original project is from 3 years ago (I am writing this in 2024). In 2021 hashlips was a good method of generating 10000 image sets. Here is the repo: https://github.com/HashLips. There are currently other methods that might be more convenient although they all come down to the same thing.
To generate 10000+ unique images what you need are different layers, such as face, body, arms, hat and for each of the layers create different options. Then toe code will randomly mix the different options to always have a unique image. Here are examples of my own (VERY POOR) nft project. I am not an artist, just curious about the technology at the time.
In the hashlips code we define all the layers, for my project I created the following layers (each layer has multuple options and are all 512 px by 512 px). In this configuration:
layersOrder
: Defines the sequence of layers, from the bottom (first) to the top (last).
growEditionSizeTo
: Sets the total number of unique NFTs to generate.
const layerConfigurations = [
{
growEditionSizeTo: 100,
layersOrder: [
{ name: "background" },
{ name: "body shape" },
{ name: "arms" },
{ name: "comment" },
{ name: "hair" },
{ name: "clothing" },
{ name: "mouth" },
{ name: "hair" },
],
},
];
layer 1: background
layer 2: body shape
layer 3: arms
layer 4: comment
layer 5: hair
layer 6: clothing
layer 7: mouth
layer 8: eyes
Above we can see an example of each layer, but we can also add rarity to options. For instance the clothing layer has 10 options, but one of those options has a rarity of 1% (so it is only chosen 1 out of every 100 times. It is shown to the right. ALthough it is still very low quality it is clear i put some more effort in the rare options in each layer.
STEP 2: Generate images
Now that we defined layers and created multiple image options for each layer we can start combining them. Note that we need to add each image in its respective folder, give it a name and end with the rarity in the name. For instance in the following example we have various image layers and for the TOP LIP layer there are three options. high#30 means is has a 30% of showing up. All options in the end add up to 100.
git clone https://github.com/HashLips/hashlips_art_engine.git
yarn install # if yarn is installed
npm install # if node is installed
What follows are all the code to set up and then run the code (after cloning we first need to add our images in the correct layer folders.
Most changes are made in the config.js file as seen below. Here is a description of the code and changes you need to make.
Image Dimensions: Customize the NFT’s size by changing the width
and height
in the format
object.
Layer Configuration: Define layers in layerConfigurations
to control the order and number of unique images generated.
Rarity Weights: Use filenames in each layer directory (e.g., Eyes/Blue#50.png
) to set rarity weights with the delimiter defined by rarityDelimiter
.
Shuffle and DNA Tolerance: shuffleLayerConfigurations
randomly orders generated images for uniqueness, while uniqueDnaTorrance
controls DNA uniqueness (higher values increase variation tolerance).
Metadata and Background: Add extra metadata for external URLs, creator names, and more, enhancing listing details on marketplaces. Customize backgrounds with colors or static images.
// General settings for the NFT collection
const basePath = process.cwd();
const { MODE } = require(`${basePath}/constants/blend_mode.js`);
const description = "This is a NFT collection made by Alex de Vries";
const baseUri = "ipfs://NewUriToReplace"; // Set this to your IPFS or other URI
// Image size (width and height) in pixels
const format = {
width: 512,
height: 512,
smoothing: false, // Set to true if you want anti-aliasing
};
// Define layer configurations for generating different editions
const layerConfigurations = [
{
growEditionSizeTo: 100,
layersOrder: [
{ name: "Background" },
{ name: "Body" },
{ name: "Eyes" },
{ name: "Mouth" },
{ name: "Accessories" },
],
},
];
// Set rarity delimiter and layer shuffling options
const rarityDelimiter = "#";
const shuffleLayerConfigurations = true;
// Additional metadata for NFT marketplaces
const extraMetadata = {
external_url: "https://alexdevri.es", // Link to your project's website
creator: "Alex de Vries",
};
// Background color configuration
const background = {
generate: true,
brightness: "80%", // Range: 0% (black) to 100% (white)
static: false, // Set to true if you want a solid background color
default: "#FFFFFF", // Hex color code for the default background
};
// Configure debugging and network settings
const debugLogs = false;
const network = "ethereum"; // Choose between 'ethereum' or other supported networks
// Define NFT metadata details
const namePrefix = "HashLips NFT";
const solanaMetadata = {
symbol: "HLP",
seller_fee_basis_points: 500, // Royalty fee in basis points (500 = 5%)
creators: [
{
address: "YourWalletAddressHere",
share: 100,
},
],
};
// Export the settings as a module
module.exports = {
format,
baseUri,
description,
background,
uniqueDnaTorrance: 10000,
layerConfigurations,
rarityDelimiter,
shuffleLayerConfigurations,
debugLogs,
extraMetadata,
namePrefix,
network,
solanaMetadata,
};
add your images to the folders then:
npm run build
If everything went correctly, and you adjusted all your setting properly there is now a build/images and build/json folder with all the relevant images. In my case it looked like this:
Again, dont judge the poor image quality. It was a one weekend project of understanding NFTs and making over a 100 layer options to generate more than 10000 unique images. It really is quite fun and still worth a try!.
Step 3: Generate NFT contract
We now have 10000 unique images, but they are not NFTs yet. Follow the the next repo to generate a nft contract for each of the images. Note taht they also need to be uploaded afterwards online for storage. https://github.com/HashLips/hashlips_nft_contract
Step 4: create crypto wallet
If you havent already, you need a crypto wallet for selling and buying NFTs. Essential for interacting with the blockchain and storing NFTs. Wallets like MetaMask are commonly used with Ethereum. Check the following link for that: https://opensea.io/learn/nft/how-to-create-an-nft
Step 5: upload NFTs to opensea
- Navigate to Your Collection: Log into OpenSea, go to your profile, and select the collection where you want to add your NFT.
- Add a New Item: Click “Add New Item” to upload your digital file (image, video, audio, etc.).
- Fill in Details: Name your NFT, add a description, and specify properties like rarity or any special attributes.
- Select Blockchain: Choose the blockchain (e.g., Ethereum, Polygon) based on your needs and gas fees.
- Mint Your NFT: Click “Create” to mint, which writes your NFT to the blockchain, making it available for sale or display.
Your NFT is now live on OpenSea, ready for others to view, buy, or collect!
Happy creating!