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 692 forks source link

Metadata trait_type #19

Closed Ponda1 closed 3 years ago

Ponda1 commented 3 years ago

How do you include the attribute trait_type in the metadata? currently, only the name of the layer element shows up and not the name of the layer. This removes the ability to add property tags to the nft when minting.

EvilShaggz commented 3 years ago

Am wondering how to fix this also

pehcastro commented 3 years ago

use v3 branch.

you can find the code on line 63 here. https://github.com/HashLips/generative-art-opensource/blob/v3/index.js

EvilShaggz commented 3 years ago

Thank you for reply i tried this and it will not return the name of the layer ie the folder name

Ponda1 commented 3 years ago

Ok Im a complete noob but I managed to solve this issue after a lot work. Basically what I did is add

var path = require('path')

to the beginning of the index file and changed the const getAttributeForElement to

const getAttributeForElement = (_element) => { let selectedElement = _element.layer.selectedElement; var parentDir = path.dirname(_element.layer.selectedElement.path); var baseDir = require('path').resolve(parentDir, '..'); var traitName = path.basename(baseDir); let attribute = { trait_type: traitName, value: selectedElement.name, rarity: selectedElement.rarity, }; return attribute; };

This now outputs the trait_type and value for each nft. :D

EvilShaggz commented 3 years ago

Ok Im a complete noob but I managed to solve this issue after a lot work. Basically what I did is add

var path = require('path')

to the beginning of the index file and changed the const getAttributeForElement to

const getAttributeForElement = (_element) => { let selectedElement = _element.layer.selectedElement; var parentDir = path.dirname(_element.layer.selectedElement.path); var baseDir = require('path').resolve(parentDir, '..'); var traitName = path.basename(baseDir); let attribute = { trait_type: traitName, value: selectedElement.name, rarity: selectedElement.rarity, }; return attribute; };

This now outputs the trait_type and value for each nft. :D

this worked for me you are a LEGEND Ponda1

Smileez1234 commented 3 years ago

Legend!

Ponda1 commented 3 years ago

Lol thanks guys i appreciate it. Just trynna help everyone out as much as I can

monticrysto commented 3 years ago

Ok Im a complete noob but I managed to solve this issue after a lot work. Basically what I did is add

var path = require('path')

to the beginning of the index file and changed the const getAttributeForElement to

const getAttributeForElement = (_element) => { let selectedElement = _element.layer.selectedElement; var parentDir = path.dirname(_element.layer.selectedElement.path); var baseDir = require('path').resolve(parentDir, '..'); var traitName = path.basename(baseDir); let attribute = { trait_type: traitName, value: selectedElement.name, rarity: selectedElement.rarity, }; return attribute; };

This now outputs the trait_type and value for each nft. :D

Sorry I know this was closed a while ago! I'm working on a macro for opensea in selenium and was wondering if it's possible in code for the traitName string to sit where "trait_type" is? So in the metadata it may show as "traitName: selectedElement.name"

Thank you for your hard work!!