NFT Metadata JSON Generator takes a CSV file with the metadata of an NFT Collection and creates a JSON file for each item with the specifications required by NFT Marketplaces such as OpenSea.
The first version of NFT Metadata JSON Generator was tailored taking into consideration the specifications of the Sublimart NFT Collection. Consider it a PoC that may evolve into a more flexible software, suitable for the needs of most NFT projects.
To run the program, clone the repository, navigate to /metadata-generator, and execute the following command:
node generate-metadata --input <PATH_TO_CSV> --ipfs <IPFS_BASE_URL>The command takes two arguments:
input: path to the csv file with your metadata.ipfs: base URL of the images directory.
In this case the csv file should include the following columns:
- name
- description
- image (file name)
- external URL
- attributes[artist]
- attributes[burn_date]
- attributes[burn_location]
- attributes[technique]
- attributes[curves]
- width
- heigh
- id
- cnt
- ligh_x
- bgcolor__001
- bgcolor__002
- bgcolor__003
Before generating the set of JSON files, all item images should have been uploaded to IPFS or any other decentralized storage platform, as the program requires the URL of the directory with all the images. E.g: ipfs://bafybeifgk4maoi7b436httwca643uq2u6yhoenc3o7yj4jsfbuatbontga/
All generated JSON files are stored inside the generated-metadata directory.
Generated JSON example:
{
"name":"Lo Abierto #1",
"description":"Florencia Giovanni Pacini is an Argentinian artist whose work has been exhibited in several national galleries. Merging both neo-romanticism and magical realism, she describes her work as figurative, poetic, narrative and dramatic, as well as being driven by feminism and ecology.",
"image":"ipfs://bafybeifjvaqfaw62pvtmsctognkawvxjsdaiemelqf4quvdgoinsfwbw7q/5-82.png",
"external_url":"https://www.sublim.art/artwork/lo-abierto@flo_giovanni_pacini",
"traits": [
{"trait_type":"Burn date","value":"2022-09-16"},
{"trait_type":"Burn location","value":"Buenos Aires"},
{"trait_type":"Curves","value":"14"},
{"trait_type":"Technique","value":"Oil on canvas"},
{"trait_type":"Artist","value":"Flo Giovanni Pacini"},
{"trait_type":"Shadow","value":"Left"},
{"trait_type":"Background color","value":"dimgray"},
{"trait_type":"Width","value":"8.5"}
]
}-
name,descriptionandexternal_urlfields in the CSV file directly map toname,descriptionandexternal URLin the JSON output. -
imageis constructed by appending thefile_namestring to theipfsconstant passed as an argument. -
The array of
traitsrepresents the atttributes of the item. -
Burn date,Burn location,Curves,Technique, andArtistvalues are directly taken from their respective fields in the CSV file. -
Shadowis calculated taking thelight_xfield, representing the direction of the projected shadow. -
Background coloris derived frombgcolor__001,bgcolor__002,bgcolor__003values, which together form an RGB color code. This code is then translated into a more friendly color name using thecolor-namerlibrary.