Skip to content

Commit

Permalink
docs: update cli docs and generate md docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alephao committed Oct 22, 2021
1 parent 9fa4d1a commit bc5d2ef
Show file tree
Hide file tree
Showing 10 changed files with 515 additions and 35 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ A suite of tools for NFT generative art.
* Generate collection rarity
* Provenance
* Generate provenance
* OpenSea
* Update metadata of collection

## Install

Expand Down Expand Up @@ -96,19 +98,9 @@ Note: if you want to generate the metadata following the erc-1155 convention for

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`.

## Usage
## Documentation

### OpenSea

*Update metadata of a collection on OpenSea*:

```sh
nftool opensea update \
--contract 0x0000000000000000000000000000000000000000 \
--from 0 \
--to 1000 \
--parallel 10 # make up to 10 parallel requests, depending on the number of cores your machine have
```
[Link to the generated docs](./docs/docs.md)

## Contributing

Expand Down
14 changes: 9 additions & 5 deletions cmd/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ var (
imgGenCmd = &cobra.Command{
Use: "gen",
Short: "Generate images from a collection.json and the layers folder",
Long: `Generate images from a collection.json and the layers folder
nftool img gen --width 800 --height 800 --collection ./collection.json --config ./config.yaml --out ./generated-imgs --parallel --png`,
Example: `nftool img gen \
--width 800 \
--height 800 \
--collection ./collection.json \
--config ./config.yaml \
--out ./generated-imgs \
--parallel`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := imgen.GenerateImagesFromCollectionAttributesJson(imgGenWidth, imgGenHeight, imgGenStartingIndex, imgGenCollectionPath, imgGenConfigPath, imgGenOutDir, imgGenParallel, imgGenSaveAsPng, imgGenOnlyMissing); err != nil {
return err
Expand All @@ -44,9 +48,9 @@ func init() {
imgGenCmd.Flags().IntVar(&imgGenHeight, "height", 0, "the height of the generated image")
imgGenCmd.MarkFlagRequired("height")
imgGenCmd.Flags().IntVar(&imgGenStartingIndex, "startingIndex", 0, "the initial index of the image names, e.g.: you have a collection of 100 and want the names to be from 1000 to 1100, use --starrtingIndex 1000")
imgGenCmd.Flags().StringVar(&imgGenCollectionPath, "collection", "", "path to the collection.json file")
imgGenCmd.Flags().StringVar(&imgGenCollectionPath, "collection", "", "path to the collection json file generated via `nftool traits make`")
imgGenCmd.MarkFlagRequired("collection")
imgGenCmd.Flags().StringVar(&imgGenConfigPath, "config", "", "path to the configuration file")
imgGenCmd.Flags().StringVar(&imgGenConfigPath, "config", "", "path to the configuration file generated via `nftool traits dump`")
imgGenCmd.MarkFlagRequired("config")
imgGenCmd.Flags().StringVar(&imgGenOutDir, "out", "", "path to the folder where all imgs will be generated")
imgGenCmd.MarkFlagRequired("out")
Expand Down
12 changes: 9 additions & 3 deletions cmd/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ var (
metadata1155Pattern bool
metadataCmd = &cobra.Command{
Use: "metadata",
Short: "generate the final metadata using a collection generated from the traits command",
Short: "Generate ERC-721 and ERC-1155 compliant metadata from a collection json generated with `nftool traits make`.",
Long: "This command will generate one file for each token, so if you have 1000 items in the collection json, it will generate 1000 files.",
Example: `nftool metadata \
--collection ./collection.json \
--config ./config.yaml \
--out ./metadata
`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := metadata.GenerateMetadata(metadataCollectionPath, metadataConfigPath, metadataOutDir, metadata1155Pattern); err != nil {
return err
Expand All @@ -26,9 +32,9 @@ var (

func init() {
// metadata
metadataCmd.Flags().StringVar(&metadataCollectionPath, "collection", "", "path to the collection json")
metadataCmd.Flags().StringVar(&metadataCollectionPath, "collection", "", "path to the collection json generated via `nftool traits make`")
metadataCmd.MarkFlagRequired("collection")
metadataCmd.Flags().StringVar(&metadataConfigPath, "config", "", "path to the config json")
metadataCmd.Flags().StringVar(&metadataConfigPath, "config", "", "path to the config json generated via `nftool traits dump`")
metadataCmd.MarkFlagRequired("config")
metadataCmd.Flags().StringVar(&metadataOutDir, "out", "", "path to the folder where the generated metadata files will be created")
metadataCmd.MarkFlagRequired("out")
Expand Down
9 changes: 7 additions & 2 deletions cmd/opensea.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ var (
openseaUpdateMaxCores int
openseaUpdateCmd = &cobra.Command{
Use: "update",
Short: "ask opensea to update the metadata of your collection",
Short: "Asks opensea to update the metadata of your collection.",
Example: `nftool opensea update \
--contract 0x0000000000000000000000000000000000000000 \
--from 0 \
--to 1000 \
--parallel 4`,
Run: func(cmd *cobra.Command, args []string) {
uptadeMetadataInRangeParallel(openseaUpdateContractAddress, openseaUpdateFrom, openseaUpdateTo, openseaUpdateMaxCores)
},
Expand All @@ -39,7 +44,7 @@ func init() {
openseaUpdateCmd.MarkFlagRequired("from")
openseaUpdateCmd.Flags().IntVar(&openseaUpdateTo, "to", 0, "the last id for a the range of ids you want to update")
openseaUpdateCmd.MarkFlagRequired("to")
openseaUpdateCmd.Flags().IntVar(&openseaUpdateMaxCores, "parallel", 1, "divide requests between your cpus, default: 1")
openseaUpdateCmd.Flags().IntVar(&openseaUpdateMaxCores, "parallel", 1, "divide requests between your cpus")
openseaCmd.AddCommand(openseaUpdateCmd)
}

Expand Down
8 changes: 5 additions & 3 deletions cmd/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ var (
provenanceCmd = &cobra.Command{
Use: "provenance",
Short: "Generate the provenace report of a collection",
Long: `Generate the provenace report of a collection
nftool provenance --imgs ./imgs --startingIndex 123 --out ./provenance.json
Long: `How provenance is generated:
First we generate the hash for each image using a SHA256 algorithm
Expand All @@ -31,6 +29,10 @@ The provenance report contains
- concatenated hashes
- hashes
- starting index`,
Example: `nftool provenance \
--imgs ./imgs \
--startingIndex 123 \
--out ./provenance.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := provenance.ProvenanceReportFromDir(provenanceImgsDir, provenanceOut, provenanceStartingIndex); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions cmd/rarity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ var (
rarityTraitsCmd = &cobra.Command{
Use: "traits",
Short: "Generate traits rarity report",
Long: "The report contains the number of appearances of each trait in the collection.",
Example: `nftool rarity traits \
--collection ./collection.json \
--out ./traits_rarity.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := rarity.MakeTraitRarityReportFromCollectionFile(rarityPath, rarityOut); err != nil {
return err
Expand All @@ -30,6 +34,10 @@ var (
rarityCollectionCmd = &cobra.Command{
Use: "collection",
Short: "Generate collection rarity report",
Long: "The report contains all the items in the collection, ordered by most rare from least rare.",
Example: `nftool rarity collection \
--collection ./out/collection.json \
--out ./out/collection_rarity.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := rarity.MakeCollectionRarityReportFromJson(rarityPath, rarityOut); err != nil {
return err
Expand Down
29 changes: 19 additions & 10 deletions cmd/traits.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ var (
traitsDumpCmd = &cobra.Command{
Use: "dump",
Short: "Generate a yaml configuration file from a directory containing all the layers and following the layer naming guidelines.",
Long: `Generate a yaml configuration file from a directory containing all the layers and following the layer naming guidelines.
Example: nftool traits dump --path /path/to/layers --out /path/to/config.yaml
Layer Naming Guidelines
Long: `Layer Naming Guidelines:
1. Layer Names
Expand Down Expand Up @@ -68,6 +64,9 @@ If you want a layer to be optional, add a "_" suffix to the folder like so:
00-Background_
Then after running 'nftool traits dump', you can change the chance of a trait not beign selected in the generated yaml file, under the "optional_weight" property.`,
Example: `nftool traits dump \
--layers ./layers \
--out ./out/config.yaml`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := traits.GenerateTraitGroupDescription(traitsPath, traitsOut); err != nil {
return err
Expand All @@ -81,9 +80,10 @@ Then after running 'nftool traits dump', you can change the chance of a trait no
traitsMakeCmd = &cobra.Command{
Use: "make",
Short: "Generate a collection from a config file or a folder with the structured layers.",
Long: `Generate a collection from a config file or a folder with the structured layers.
Example: nftool traits make --path path/to/layers --out ./collection.json --amount 8888`,
Example: `nftool traits make \
--amount 10 \
--config ./config.yaml \
--out ./collection.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := traits.GenerateTraitCollection(traitsPath, traitsOut, traitsMakeAmount); err != nil {
return err
Expand All @@ -94,8 +94,9 @@ Example: nftool traits make --path path/to/layers --out ./collection.json --amou

// traits shuffle
traitsShuffleCmd = &cobra.Command{
Use: "shuffle",
Short: "shuffle a collection json",
Use: "shuffle",
Short: "shuffle a collection json",
Example: `nftool traits shuffle --path ./collection.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := traits.ShuffleCollection(traitsPath); err != nil {
return err
Expand All @@ -108,6 +109,10 @@ Example: nftool traits make --path path/to/layers --out ./collection.json --amou
traitsMergeCmd = &cobra.Command{
Use: "merge",
Short: "Merge multiple attributes files in one, ignoring collisions",
Example: `nftool traits merge \
--file ./collection_1.json \
--file ./collection_2.json \
--out ./collection_merged.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := traits.MergeCollections(traitsPaths, traitsOut); err != nil {
return err
Expand All @@ -120,6 +125,10 @@ Example: nftool traits make --path path/to/layers --out ./collection.json --amou
traitsCollisionsCmd = &cobra.Command{
Use: "collisions",
Short: "Find collisions from multiple collection files and generate a report",
Example: `nftool traits collisions \
--file ./collection_1.json \
--file ./collection_2.json \
--out ./collision_report.json`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := traits.FindCollisions(traitsPaths, traitsOut); err != nil {
return err
Expand Down
Loading

0 comments on commit bc5d2ef

Please sign in to comment.