Git Product home page Git Product logo

nftool's Introduction

nftool

Tests

A suite of tools for NFT generative art.

Features

  • Metadata
    • Generate ERC-721 and ERC-1155 compatible metadata
  • Traits/Attributes/Properties Generation
    • Configure custom rarity
    • Generate collection attributes configuration file
    • Merge collections
    • Shuffle collection
    • Find collisions between collections
  • Image Generation
    • Generate images from collection description
    • Generate images in parallel
    • Generate only missing images (if you delete a few images from the output folder)
  • Rarity
    • Generate traits rarity
    • Generate collection rarity
  • Provenance
    • Generate provenance
  • OpenSea
    • Update metadata of collection

Install

Homebrew on Macos

brew install alephao/formulae/nftool

Using Go

go install github.com/alephao/nftool@latest

Or clone the repository, change to the root folder and run go install.

Manually

Download the binary from the releases page and move it to your bin path like /usr/local/bin.

Getting Started

To get started, install nftool following the instructions above and cd to the examples folder in this repo.

You can always use nftool help [command] to see all the documentatio and all the options of a command.

First generate the configuration file from the layers folders.

mkdir -p out
nftool traits dump --layers ./layers --out ./out/config.yaml

You can open config.yaml and play around with the rarity weights, and optional configuration.

Then generate a collection from the config.yaml

nftool traits make --amount 10 --config ./out/config.yaml --out ./out/collection.json

Now we can use the collection.json to generate the images. Run the following commands:

mkdir -p ./out/images
nftool img gen --width 300 --height 300 --collection ./out/collection.json --config ./out/config.yaml --out ./out/images

We can also generate rarity reports for traits (which trait is more rare and how many times it shows up) and the collection rarity rank.

# Generate traits rarity report
nftool rarity traits --collection ./out/collection.json --out ./out/traits_rarity.json

# Generate collection rarity rank report
nftool rarity collection --collection ./out/collection.json --out ./out/collection_rarity.json

To generate the provenance for this collection it's easy:

nftool provenance --images ./out/images --out ./out/provenance.json --startingIndex 2

Note: the startingIndex should be a number smaller than the total amount of items in the collection and it's usually generated on-chain.

Now we need to generate the actual metadata that we'll upload to IPFS (or another storage service).

	mkdir -p ./out/metadata
	# Generate ERC-721 metadata
	nftool metadata --collection ./out/collection.json --config ./out/config.yaml --out ./out/metadata

Note: if you want to generate the metadata following the erc-1155 convention for the id/file-name, add the flag --erc1155

Check out the output in ./out/metadata/1. If you want to change anything, you can do so by editing the values in ./out/config.yaml.

Documentation

Link to the generated docs

Contributing

  • For requests and questions, please open an issue.
  • PRs accepted.

Releasing

To release a new version

git tag vx.x.x
git push origin vx.x.x
goreleaser release --rm-dist  

License

MIT © Aleph Retamal

nftool's People

Contributors

alephao avatar misantron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nftool's Issues

png image size

Hi,
First I have to say, this is a pretty cool tool! Thanks for that.

I have an issue with the file size of the png images. They are about 25 MB and they should be about 40 kB.
Is there a solution for this?
I've been messing about with the imgen.go file and put in BestCompression but this doesn't solve the file size.

Looking forward to hear from you!

Adjust output images dimensions

Looks like the weight and height property of nftool images doesn't adjust output dimension.

For example, the traits all have 3000x3000 dimension, but I want the output to be 1080x1080 to save size.

Specifying 1080 for height and weight in nfttool images gives distorted images. It works fine when the orig dimension is provided (3000).

Does the library support this?

Rarity Weight

❤❤❤❤❤❤❤
Hi, I was trying to generate arts with the exact weights, finally, I found this module and tried.
But I was a bit surprised because I didn't see the result that I wanted.

Layer Structure

    00-Background
        |- 1.blue.png
        |- 2.white.png
        |- 3.green.png
    01-Body
        |- 1-maroon.png
        |- 2-nut.png
        |- 3-standard.png
        |- 4-yellow.png
    02-Expressions
        |- 1-dot.png
        |- 2-std_lord.png
        |- 3-standard.png

config.yaml

name: 'My Collection #{id}'
description: An awesome collection
external_link: https://myexternallink.com
image: ipfs://myHash/{id}
traits:
- trait_type: Background
  variants:
  - value: blue
    weight: 1
  - value: white
    weight: 2
  - value: green
    weight: 3
  is_optional: false
  optional_weight: 1
- trait_type: Body
  variants:
  - value: maroon
    weight: 1
  - value: nut
    weight: 2
  - value: standard
    weight: 3
  - value: yellow
    weight: 4
  is_optional: false
  optional_weight: 1
- trait_type: Expressions
  variants:
  - value: dot
    weight: 1
  - value: std_lord
    weight: 2
  - value: standard
    weight: 3
  is_optional: false
  optional_weight: 1
path_map:
  Background/blue: ./layers/00-Background/1-blue.png
  Background/green: ./layers/00-Background/3-green.png
  Background/white: ./layers/00-Background/2-white.png
  Body/maroon: ./layers/01-Body/1-maroon.png
  Body/nut: ./layers/01-Body/2-nut.png
  Body/standard: ./layers/01-Body/3-standard.png
  Body/yellow: ./layers/01-Body/4-yellow.png
  Expressions/dot: ./layers/02-Expressions/1-dot.png
  Expressions/standard: ./layers/02-Expressions/3-standard.png
  Expressions/std_lord: ./layers/02-Expressions/2-std_lord.png

traits_rarity.json

  {
    "total": 30,
    "traits": {
      "Background": {
        "blue": { "Total": 9, "Percentage": 0.3 },  //  Origin: 5               
        "green": { "Total": 10, "Percentage": 0.3333333333333333 }, // Origin: 10
        "white": { "Total": 11, "Percentage": 0.36666666666666664 } // Origin: 15
      },
      "Body": {
        "maroon": { "Total": 4, "Percentage": 0.13333333333333333 },  //  Origin: 3
        "nut": { "Total": 9, "Percentage": 0.3 }, //  Origin: 6
        "standard": { "Total": 8, "Percentage": 0.26666666666666666 },  //  Origin: 9
        "yellow": { "Total": 9, "Percentage": 0.3 } //  Origin: 12
      },
      "Expressions": {
        "dot": { "Total": 10, "Percentage": 0.3333333333333333 }, //  Origin: 5
        "standard": { "Total": 11, "Percentage": 0.36666666666666664 }, //  Origin: 10  
        "std_lord": { "Total": 9, "Percentage": 0.3 } //  Origin: 15
      }
    }
  }

🙋‍♂️ Please let me know what I made a mistake, and how I can solve this problem perfectly.

🙏 Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.