HashLips / generative-art-opensource

Create generative art by using the canvas api and node js, feel free to contribute to this repo with new ideas.
MIT License
1.36k stars 695 forks source link

Generate single metadata for each images #37

Closed Mesyme closed 2 years ago

Mesyme commented 2 years ago

Greetings! first, thanks for your work, you are the best :) I would like to use the main version, instead of v3, because thanks to the commit of caiaga, it is possible to choose the percentage of the trait. But I would also like to be able to generate a single metadata for each images. I tried to copy the code from v3, but it didn't work

const saveMetaDataSingleFile = (_editionCount) => {
  fs.writeFileSync(
    `./output/${_editionCount}.json`,
    JSON.stringify(metadataList.find((meta) => meta.edition == _editionCount))
  );
};

saveMetaDataSingleFile(editionCount);

error

[m@march generative-art-opensource-main]$ node index.js
##################
# Generative Art
# - Create your NFT collection
##################

start creating NFTs.
-----------------
creating NFT 1 of 10
- rarity: original
use random rarity super_rare
- dna: 05-00-02-02-02-02
node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFileSync (node:fs:2146:5)
    at saveMetaDataSingleFile (/home/m/Downloads/generative-art-opensource-main/index.js:175:6)
    at /home/m/Downloads/generative-art-opensource-main/index.js:253:7
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async startCreating (/home/m/Downloads/generative-art-opensource-main/index.js:237:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}