nftgen 0.0.2+1 copy "nftgen: ^0.0.2+1" to clipboard
nftgen: ^0.0.2+1 copied to clipboard

NFT unqiue image generator and metadata analyzer, available on library and command line.

nftgen #

NFT unqiue image generator and metadata analyzer. It can be used as a Dart library or from the command line.

There are still many things to complete or add.

The general procedure is as follow:

  1. Generate config file based on layers directory
  2. Adjust probabilities in config file manually
  3. Generate NFTs and metadata files
  4. Analyse NFT rarity distribution, backtrace to 2.
  5. Upload NFT images and get a CID manually
  6. Update config file with CID manually
  7. Update all metadata files with CID automatically
  8. Upload metadata files manually

Which boils down to these commands:

  1. nftgen config ...
  2. ( ... )
  3. nftgen nft ...
  4. nftgen rarity ...
  5. ( ... )
  6. ( ... )
  7. nftgen cid ...
  8. ( ... )

TODO #

  • Figure out automatic setting of weights and probabilities for nice distribution of NFTs.
  • Implement proper command line invocation.
  • Separate NFT generation from metadata generation.

Quickstart #

Create a config, generate NFTs and analyze rarity based on the provided example layers:

dart pub global activate nftgen

nftgen config .\assets\layers\ .\assets\config_gen.json 0.0 "Background,Eyeball,Eye color,Iris,Shine,Bottom lid,Top lid"

nftgen nft .\assets\layers\ .\assets\config_gen.json .\assets\images\ .\assets\meta\

// Or create metadata only to validate rarity distribution (Faster) // Adjust config file until rarity distribution is OK

nftgen nft .\assets\layers\ .\assets\config_gen.json .\assets\images\ .\assets\meta\ metaonly

nftgen rarity .\assets\meta\ .\assets\rarity_nft.csv .\assets\rarity_layers.csv

Config #

{
  // how many NFTs to generate
  "maxNfts": 250, 
  // run "nftgen cid" to update the metadata files
  "cidCode": "your CID code", 
  // the order of layer entries matters
  "layers": [ 
    {
      // shown in generated metadata JSON
      "name": "Eyeball",  
      // your local directory
      "directory": "Eyeball",
      // probability: 0.0...1.0 = 0...100% 
      "probability": 1.0, 
      "weights": {
        // probability: 1 / 17
        "Red#50.png": 1, 
        // probability: 16 / 17
        "White#50.png": 16 
      }
    },
    ...
}

Layer: The config allows for assinging a percentage to each individual layer between 0.0 and 1.0, setting the probability that this layer will be used in an NFT.

Layer Image: The config allows for assigning weights to indivividual images of each layer (layer = trait).

Generate: The config can be generated by pointing to a directory holding all NFT layers. The generated config will be simplistic.

For example, the following command will generate a config with equal weight distribution (0.0) and respecting the order of the given directories ("c,b,a"):

nftgen config .\assets\layers\ .\assets\config_gen.json 0.0 "Background,Eyeball,Eye color,Iris,Shine,Bottom lid,Top lid"

The more NFTs to generate, the steeper the weights within each layer have to be, this can be achived setting the exponential factors to 2.0, 3.0, 4.0 etc.

 x*2 1,4,9,16,...
 x^3 1,8,27,64,125,216,343,512
 x^4 1, 16, 81, 256, 625, 1296, 2401, 4096

Also, the probability of the most rare layers can be set to e.g. 0.25, 0.5, 1.0, 2.0 etc.

How to Use #

Library #

Please refer to the API for details, some functions have additonal parameters.

final sep = Platform.pathSeparator;
final assets = Directory('assets');

final layersDir = Directory('${assets.path}${sep}layers');
final imagesDir = Directory('${assets.path}${sep}images');
final metaDir = Directory('${assets.path}${sep}meta');

final csvNft = File('${assets.path}${sep}rarity_nft.csv');
final csvLayers = File('${assets.path}${sep}rarity_layers.csv');

// Write config JSON based on layers directory.

final Map<String, dynamic> config = Config.generate(layersDir, factor: 3);
final configFile = File('${assets.path}${sep}config_generated.json');
Io.writeJson(configFile, config);

// Generate NFTs based on config JSON.

Nft.generate(configFile, layersDir, imagesDir, metaDir);

// Analyze generated NFT metadata and save it

final nftAnalysis = Rarity.nfts(metaDir);
final layersAnalysis = Rarity.layers(metaDir);
Io.save(nftAnalysis, csvNft);
Io.save(layersAnalysis, csvLayers);

// Update metadata json with CID code given in config.
// Adjust cidCode in config before running this command.

Config.updateCidMetadata(configFile, metaDir);

Command Line #

  • Activate shell command: dart pub global activate nftgen

  • Deactivate shell command: dart pub global deactivate nftgen

USAGE

  • Generate a config-json file:

nftgen config <IN-LAYERS-DIR> <OUT-CONFIG-FILE> [<WEIGHT-FACTOR>:3.0]

  • Generate NFTs based on a config-json file:

nftgen nft <IN-CONFIG-FILE> <IN-LAYERS-DIR> <OUT-IMAGE-DIR> <OUT-META-DIR>

  • Add CID code read from config or given as parameter to metadata files:

nftgen cid <IN-CONFIG-FILE> <OUT-META-DIR> [<CID>, <CID-REPLACE>]

  • Generate rarity reports basd on metadata directory:

nftgen rarity <IN-META-DIR> <OUT-RARITY-NFT.CSV> <OUT-RARITY-LAYERS.CSV>

EXAMPLES

  • Generate a config with equal weight distribution and ordered layers:

nftgen config .\assets\layers\ .\assets\config_gen.json 0.0 "Background,Eyeball,Eye color,Iris,Shine,Bottom lid,Top lid"

  • Generate NFTs based on a config:

nftgen nft .\assets\layers\ .\assets\config_gen.json .\assets\images\ .\assets\meta\

  • Add CID code given as parameter to config and metadata:

nftgen cid .\assets\config_gen.json .\assets\meta\ NEW-CID-CODE OLD-CID-CODE

  • Replace CID with CID-REPLACE read from config to metadata:

nftgen cid .\assets\config_gen.json .\assets\meta\

  • Generate rarity reports basd on metadata directory:

nftgen rarity .\assets\meta\ .\assets\rarity_nft.csv .\assets\rarity_layers.csv

References #

The example layers are from Hashlips (MIT livense):

https://github.com/HashLips/hashlips_art_engine

License #

MIT

0
likes
0
pub points
0%
popularity

Publisher

verified publishernovelplotter.com

NFT unqiue image generator and metadata analyzer, available on library and command line.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

crypto, image, io, path

More

Packages that depend on nftgen