Generates images and metadata for a collection of NFTs.
This is a simple Node.js project that uses a list of pre-configured traits and image layers to generate a unique set of images and metadata files for a collection of NFTs. You would be able to create your own collection by updating the traits configuration and the image layers.
Clone the repo
git clone https://github.com/manuelpires/nft-collection-generator.git
Inside the repo directory install NPM packages
npm install
There's an example configuration in the config.js
file, and there's also some pre-defined image layers in the traits
folder. You can test and run this project with that pre-existing configuration to see first how everything works and to see the results.
Test the current configuration in the config.js
file
npm test
This will only test if the current configuration is correct or not.
Run the project with the current configuration
npm run build
This will execute the main script. If successful, it will:
After running the project, you can update the images base URI inside all generated metadata files by running:
npm run update-base-uri
This will take the current value of IMAGES_BASE_URI
inside config.js
and use it to update all metadata files.
After running the project, you can create a GIF using the generated images:
npm run create-gif
After running the project, you can launch the following script to calculate the SHA-256 hash of every image generated and also print the final provenance hash of all of them:
npm run calculate-hashes
To create your own collection of unique tokens, you'd have to edit only the config.js
file and update the image layers in the traits
folder.
The metadata generated by running this project should be compatible with OpenSea's Metadata Standards. If you are not familiarized with those standards, you should give that page a read as it would help a lot to understand how to update the config.js
file. Also, make sure to first run the project with the example configuration and check out the generated metadata files for more clarification about the process.
These are the constants that you'd need to update in the config.js
file:
config.GIF_FRAMES = 10; // only if you want to generate a GIF
config.IMAGES_BASE_URI = "https://base-uri-to-my-nft-images.com/";
config.IMAGES_HEIGHT = 350;
config.IMAGES_WIDTH = 350;
config.TOKEN_NAME_PREFIX = "My NFT #";
config.TOKEN_DESCRIPTION = "My NFT description.";
config.TOTAL_TOKENS = 100;
You'd also have to modify the last variable called ORDERED_TRAITS_LIST
that contains the array of all available traits for the tokens.
Each trait has the following structure:
{
display?: string;
ignore?: boolean;
type?: string;
options: {
allowed?: string[];
forbidden?: string[];
image?: string;
value?: string | number;
weight: number;
}[]
}
Before modifying the traits list, please go through the next important instructions:
ignore: true
.config.js
file. In this case an "Orchid" triangle would only be available for tokens with "Coral" or "Mint" backgrounds; and also a "Teal" triangle will not be available for tokens with "Robin" background.TOTAL_TOKENS
is too big when you try to run it.Running the command
npm test
will verify that these set of rules are taken into account within your current configuration, and that the generated metadata would follow the standards. Use it!
Distributed under the MIT License. See LICENSE
for more information.
Manuel Pires - [email protected]
Project Link: https://github.com/manuelpires/nft-collection-generator