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
,description
andexternal_url
fields in the CSV file directly map toname
,description
andexternal URL
in the JSON output. -
image
is constructed by appending thefile_name
string to theipfs
constant passed as an argument. -
The array of
traits
represents the atttributes of the item. -
Burn date
,Burn location
,Curves
,Technique
, andArtist
values are directly taken from their respective fields in the CSV file. -
Shadow
is calculated taking thelight_x
field, representing the direction of the projected shadow. -
Background color
is derived frombgcolor__001
,bgcolor__002
,bgcolor__003
values, which together form an RGB color code. This code is then translated into a more friendly color name using thecolor-namer
library.