This is a fork of Hashlip's art engine. It is currently a Work in Progress as more features are planned to be added.
🛠️🛠️ Please note that the README is barebones atm as I'm still working on feature implementation, but if you have any questions, please feel free to ask me in the various channels I can be reached.
- cleanMetadata
- removeAttributes
- renameAttributes
- generateOldDna
- recreateAndSortMetadata
- rarityFromMetadata
- Work in Progress
This fork gives the option to use a simpler weight system by using common rarity names (Common, Uncommon, Rare, Epic, Legenedary, and Mythic) instead of numbers. Weight will be calculated based on named value.
This repository is set up to use named weights by default. The layers are already using named weights
You can switch back to using numbered weights by setting namedWeight
to false in config.js.
// Set this to true if you want to use named rarity instead of numbers.
const namedWeight = true;
This fork gives the option to use define exact counts of traits rather than using weight to randomly determine counts of traits.
To use exact weight system, set exactWeight to true in config.js. When this option is enabled, the weight any given trait is set to will be the exact number of times that trait appears in the collection. ie: trait#50.png
will appear 50 times throughout the collection exactly.
PLEASE NOTE: exactWeight and namedWeight can not be used together at this time!
const exactWeight = true;
Use this option to assign a 'variation' to multiple layers. The most common use-case for this option would be ensuring certain traits are the same color or skin pattern. For any trait that has variations, put a placeholder in the normal layer's folder with the desired weight, then put each of it's variations into the layer's '-variant' folder named with the variant name instead of a weight.
Define your variations in the layerVariations const in config.js.
NOTE: If a layer has variations, it must contain all the variants. For example, the base images in this fork have 4 variants defined (Blue, Green, Purple, and Red), so any layer using layerVariations must include a variant for each of those colors.
In this fork, there are currently two layers with variations (Arms and Head). If you look at the file structure, you will see each have '-variant' folders with each trait duplicated the number of colors edfined in layerVariations. Define layerVariations:
const layerVariations = [
{
variationCount: 1,
name: 'Color',
variations: [
'Blue',
'Green',
'Purple',
'Red',
],
Weight: [
35,
25,
25,
15,
],
},
];
Determine which layers need variants:
{ name: "Arms", options: {layerVariations: 'Color'} },
Base folder for the trait (Arms) as well as it's variant folder (Arms-variant):
Base trait folder contents. These files should be named the same way any other trait would be (trait#weight):
Variant folder contents. These files should be named with the traits name (exactly matching that in the base trait folder) followed by a space and the variant's name (the four colors in this case):
Add any number of stats to your tokens! All examples are from the Opensea Metadata Standards. Please visit to see how each display_type will look on Opensea.
To use stat blocks, simply set enableStats
to 'TRUE' in config.js.
const enableStats = true;
You can randomize the value in each new attribute in const statBlocks
. You can control the range of the value
by defining minValue
& maxValue
.
NOTE: Leave value
set to '0' here. If you change it, the generated value may fall outside the range set by minValue
& maxValue
.
{
minValue: 1,
maxValue: 999,
attribute:
{
display_type: "number",
trait_type: "Stamina",
value: 0
},
},
The generated trait in the example above will add a trait like this to the metadata:
{
"display_type": "number",
"trait_type": "Stamina",
"value": 84
},
Allows adding extra attributes to the metadata. extraMetadata
is restricted to only adding things outside the attribute. This functionality allows adding extra information to the attributes so they can be displayed in marketplaces.
NOTE: This will add the same information to each NFT's metadata.
This works similarly to the already present extraMetadata
, but you can add multiple items. Anything added to this section will be added to every NFT's metadata.
const extraAttributes = [
{
trait_type: "New Trait",
value: "Extra",
}
];
This fork gives the ability to start generation at any number. This can sometimes be useful, but in 99% of cases generation should be done all at once. These options simply provide tools for the other 1%. Utilizing a previous generations dna will help to prevent duplicates from being generated. Please be sure to utilize the oldDna Util.
resumeNum
can be set independantly to simply start edition at a higher number, but if you want to use old dna, your resumeNum
must be set and it must equal the number of items in _oldDna.json
const resumeNum = 0;
const importOldDna = false;
Adjusting every growEditionSizeTo
anytime you want to test something out on a smaller scale can be frustrating. This system allows you to set your collectionSize
once, then your growEditionSizeTo
definitions are replaced with scaleSize. Ensure the numbers fed to that function add up to your collectionSize
, and you can change toCreateNow
on the fly to whatever scale you want to test. All rarity is scaled where applicable, so no need to make weight adjustments!
By default, this repository is not using this system. To enable it, simply change growEditionSizeTo
to use scaleSize()
instead of a number.
growEditionSizeTo: scaleSize(300),
// instead of
growEditionSizeTo: 300,
NOTE: If you do use this feature, collectionSize
and toCreateNow
must match to create the full collection!
TIP: To avoid potential scaling issues, you can set your final layersOrder to equal collectionSize
.
const collectionSize = 1000;
const toCreateNow = 1000;
const scaleSize = (num) => {
if (collectionSize === toCreateNow) return num;
return Math.ceil((num / collectionSize) * toCreateNow);
};
If you want duplicates in your collection, you can set the allowDuplicates flag to true.
const allowDuplicates = true;
If you need to adjust your DPI, that has been added as an option in config.js under format
.
const format = {
width: 512,
height: 512,
dpi: 72,
smoothing: false,
};
This utility gives the option to remove some commonly requested items. Set any to true to remove them from generated metadata. Original metadata is preserved, and clean metadata is saved to build_new/json
let removeDna = true;
let removeEdition = false;
let removeDate = true;
let removeCompiler = false;
This utility gives the ability to remove any attributes either by trait_type or value. Commonly used to remove 'None', but can be set to remove any attribute. Add each item you'd like removed from the attributes to the removeValue
and/or removeTraitType
arrays:
let removeValue = [ "None", "Test" ] //Enter values you want to remove here. (ie: "None")
let removeTraitType = [ "Head" ] //Enter a Traits you want to remove here. (ie: "Head")
This utility gives the ability to rename any attributes either by trait_type or value. Simply enter the values and/or trait types that you want to replace into valueBefore
and/or traitTypeBefore
, and what you want them replaced with in valueAfter
and/or traitTypeAfter
.
NOTE: Arrays must be the same length and be in the correct order for replacement to work properly. In the example, "FishHead" will be replaced with "StandardHead", "Purple" will be replaced with "Lavender", etc.
let valueBefore = [ "FishHead", "Purple" ] //Enter old values here
let valueAfter = [ "StandardHead", "Lavender" ] //Enter new values here
let traitTypeBefore = [ "test", "Color" ] //Enter old trait_types here
let traitTypeAfter = [ "Hat", "Skin" ] //Enter new trait_trypes here
This utility generates a dnaList for import from a previous generation's metadata. As mentioned several times, the better options is typically to regenerate everything; however, this gives the ability to prevent duplicates from being generated based on old information.
You must place your previously generated _metadata.json file in the build_old folder.
This utility recreates all individual metadata files as well as _metadata.json and orders them numerically. This can be useful if _metadata.json was accidentally deleted from the build folder or if you need each item in _metadata.json to be ordered numerically.
No edits necessary to use this util.
This utility counts all traits and calculates their occurence percentages, calculates scores based on each NFT's traits, ranks each NFT by their score, and determines their named rarity (Common, Uncommon, Rare, Epic, Legendary, Mythic). It also enables the ability to add any or all of this information to the metadata itself as it's own element or as an attribute!
NOTE: This utility replaces the old 'rarity.js' script. 'yarn rarity' will now call this utility.
NOTE: Due to a change in how traits are determined, this will no longer display any 0 qty traits. Be sure to review 'rarityBreakdown' in the rarity folder.
NOTE: Any attribute with display_type will not include occurance percentage in the value, even if includeTraitPercentages
is set to true to avoid issues with displaying properly on marketplaces.
By default, Rank will be added as an attribute and Rarity will be added as an element to the metadata when running this utility. You can adjust what will be added to the metadata by editing these items:
const scoreAttribute = false;
const scoreElement = false;
const rankAttribute = false;
const rankElement = true;
const rarityAttribute = true;
const rarityElement = false;
const includeTraitPercentages = false;
scoreAttribute will add a trait to the metadata like:
{
"trait_type": "rarityScore",
"value": 173
}
rankAttribute will add a trait to the metadata like:
{
"trait_type": "Rank",
"value": 29
}
rarityAttribute will add a trait to the metadata like:
{
"trait_type": "Rarity",
"value": "Rare"
}
includeTraitPercentages will add occurence percentages to all other traits like:
{
"trait_type": "Color",
"value": "Red (12.00%)"
}
🛠️🛠️ Note again that the engine and especially documentation are a work in progress. Both will be improved upon further.
Mark specific items to be moved the first n of the collection for sequential minting.