The metadata tool simplifies the process for creating complicated token factories and associating tokens with those factories. This tool allows the user to specify token factory specifications and corresponding token(s) specifications in an easy to use CSV template.
This tool takes CSVs and media files (Uniq images, videos and other supported media files) as input, converts to files to JSON objects, validates the JSON data, generates sha256
hashes of the JSON objects and outputs the generated JSON files.
Note that the tool itself does not interact with the blockchain; rather, it simplifies the process of creating complicated token factories and the associated tokens.
There are two ways of obtaining the tool:
- You can download the latest release of the tool from here.
- [Optional] Create a
config.json
file in the same directory as your binary/executable. Refer to Configuration file section for more info on the config file.
You can manually build the binary/executable of the tool by cloning the repository on your system and following these steps:
- Install dependencies using
npm i
. - Build the package using
npm run build
and it will generate the releases under/releases
directory. - [Optional] Create
config.json
file in the same directory where your binary/executable is present. Refer to Configuration file section for more info on the config file. - Run the generated binary using:
./releases/metadata-tool-vX-Y-Z-linux
The configuration file (config.json
) is a JSON object that allows user to map environment names to their corresponding base URIs. Each environment corresponds to a specific environment in which the metadata and media file for token factory and associated token(s) are to be be hosted/uploaded.
Here's an example of what the config file might look like:
{
"environments": {
"production": "https://www.my-nft-website.com",
"staging": "https://staging.my-nft-website.com",
"mys3bucket": "https://s3.us-east-1.foobar.com",
"custom": "https://www.my-custom-env.com"
},
"preserveNewLineCharacters": true
}
In the example above, the production
, staging
, mys3bucket
and custom
environments are mapped to their corresponding base URIs. When the tool is run, it will read the config file and will prompt the user to select either one of the provided environments. The corresponding URI for the selected environment will be used as base URI for the generated factory and token(s).
Note that the environments and base URIs in the config file shown above are just examples, and you should replace them with the actual environment(s) for your use-case.
Note: If you do not provide a config file, the tool will prompt you to enter a base URI.
Additional option preserveNewLineCharacters
will ensure that the \n
characters in the descriptions will remain unchanged in the output JSON file. Otherwise, they will be escaped twice as \\n
.
Once you have obtained the tool, next step is to setup the folder structure along with the media files and adding data to the CSV template.
However there are a few things to note.
- A report is always generated during runtime.
- However, reports are not generated until you close the program.
- Reports will help you debug your CSV files, any missing information will be posted to the report and sometimes in the terminal / console window.
It is recommended to use the following folder setup for ease of use.
MyFirstUniq/ 📁 (This is your Root Folder)
|- factory.csv
|- tokens.csv
|
|- factory/ 📁
| |- sq.png
| |- product.png
| |- gallery/ 📁
| |- 1.png
|
|- tokens/ 📁
|- 1 📁
| |- image.png
| |- gallery/ 📁
| |- 1.png
|
|- 2 📁
| |- image.png
| |- gallery/ 📁
| |- 1.png
However, the folder structure can be modified and replaced with a single folder that contains CSV files and relevant images/media files.
- Use the following CSV template: Google Sheets Metadata Tool Template (Visit the link and go to
File -> Make a Copy
to make a copy in your own Google Drive). - Open your copied CSV template in your Google Drive and begin modifications of individual fields. (Read the first sheet for information regarding the template).
- Export both
factory
andtokens
sheets as CSV files.File -> Download -> csv
- Rename factory file to
factory.json
and place in your root folder. (See Folder Structure Above) - Rename token file to
tokens.json
and place in your root folder.
There are two ways to link to an image/media file in your CSV file. One is relative path, and the other is an external HTTP or HTTPS address.
- Relative Path:
./tokens/1/image.png
(Relative to your root folder) - External:
https://some-external-website.com/tokens/1/image.png
The tool currently only supports the follow media types:
- jpg / jpeg
- png
- bmp
- gif
- webp
- mp4
- webm
- json
All media files are copied and renamed to their hash value. For example, if you have a media file /factory/sq.png
, it will be copied, and renamed to /generated_media/<hash>.png
.
Once the CSV files and all related images/media files are present in the folder, you can process the folder for JSON creation.
-
Drag & Drop the Folder onto the Executable
a. Watch the console window for errors.
b. If errors have occurred, you can check the report generated after closing the application
-
If there are no errors, a
upload.json
file will be generated in your root folder.
The upload.json
file contains all metadata (collection name, factory/token hashes & URLs, media URLs) for your Uniq collection. A sample output file might look like this:
(This example is based on the sample folder structure provided above.)
{
"collectionName": "MyFirstUniq",
"factory": {
"hash": "<sha256-of-factory.json>",
"url": "https://www.my-nft-website.com/MyFirstUniq/<sha256-of-factory.json>.json"
},
"defaultToken": {
"hash": "<sha256-of-defaultToken.json>",
"url": "https://www.my-nft-website.com/MyFirstUniq/{serial_number}.json"
},
"tokens": [
{
"serialNumber": "1",
"hash": "<sha256-of-1.token.json>",
"url": "https://www.my-nft-website.com/MyFirstUniq/1.json"
},
{
"serialNumber": "2",
"hash": "<sha256-of-2.token.json>",
"url": "https://www.my-nft-website.com/MyFirstUniq/2.json"
}
],
"media": {
"generated_media/<hash-of-file1>.png": "https://www.my-nft-website.com/MyFirstUniq/<hash-of-file1>.png",
"generated_media/<hash-of-file2>.png": "https://www.my-nft-website.com/MyFirstUniq/<hash-of-file2>.png",
"generated_media/<hash-of-file3>.png": "https://www.my-nft-website.com/MyFirstUniq/<hash-of-file3>.png",
.....
.....
},
"environment": {
"env": "production",
"tokenUriTemplate": "{serial_number}",
"url": "https://www.my-nft-website.com",
"toolVersion": "1.4.0"
}
}
Note that the URLs provided in the output file are based on the environment URIs that were provided to the program. These URLs are where your Uniq metadata files should be hosted/uploaded.