diff --git a/CIP-0025/README.md b/CIP-0025/README.md index 1d39c9a1c8..7ae72b7b20 100644 --- a/CIP-0025/README.md +++ b/CIP-0025/README.md @@ -38,7 +38,7 @@ This is the registered `transaction_metadatum_label` value | --------------------------- | ------------ | | 721 | NFT Metadata | -### Structure +### General structure The structure allows for multiple token mints, also with different policies, in a single transaction. @@ -50,7 +50,7 @@ The structure allows for multiple token mints, also with different policies, in "name": , "image": , - "mediaType": "image/", + "mediaType": image/, "description": , @@ -64,27 +64,36 @@ The structure allows for multiple token mints, also with different policies, in } }, - "version": "1.0" + "version": } } ``` -The **`asset_name`** must be `UTF-8` encoded for the key in the metadata map and the actual NFT. This is true for version `1.0`, future versions will use the `hex` encoding for **`asset_name`**. +### CDDL -The **`image`** and **`name`** property are marked as required. **`image`** should be an URI pointing to a resource with mime type `image/*` used as thumbnail or as actual link if the NFT is an image (ideally <= 1MB). +[Version 1](./cddl/version_1.cddl)\ +[Version 2](./cddl/version_2.cddl) -The **`description`** property is optional. +- In version `1` the **`asset_name`** must be `utf-8` encoded and in text format for the key in the metadata map. In version `2` the the raw bytes of the **`asset_name`** are used. -The **`mediaType`** and **`files`** properties are optional.
**`mediaType`** is however required inside **`files`**. The **`src`** property inside **`files`** is an URI pointing to a resource of this mime type. If the mime type is `image/*`, **`mediaType`** points to the same image, like the on in the **`image`** property, but in an higher resolution. +- In version `1` the **`policy_id`** must be in text format for the key in the metadata map. In version `2` the the raw bytes of the **`policy_id`** are used. -The **`version`** property is also optional. If not specified the version is `1.0`. It will become mandatory in future versions if needed. +- The **`image`** and **`name`** property are marked as required. **`image`** should be an URI pointing to a resource with mime type `image/*` used as thumbnail or as actual link if the NFT is an image (ideally <= 1MB). -This structure really just defines the basis. New properties and standards can be defined later on for varies uses cases. That's why there is an "other properties" tag. +- The **`description`** property is optional. -The retrieval of the metadata should be the same for all however. +- The **`mediaType`** and **`files`** properties are optional.
**`mediaType`** is however required inside **`files`**. The **`src`** property inside **`files`** is an URI pointing to a resource of this mime type. If the mime type is `image/*`, **`mediaType`** points to the same image, like the on in the **`image`** property, but in an higher resolution. + +- The **`version`** property is also optional. If not specified the version is `1`. It will become mandatory in future versions if needed. + +- This structure really just defines the basis. New properties and standards can be defined later on for varies uses cases. That's why there is an "other properties" tag. + +- The retrieval of the metadata should be the same for all however. Optional fields allow to save space in the blockchain. Consequently the minimal structure for a single token is: +#### Version 1 + ``` { "721": { @@ -98,6 +107,22 @@ Optional fields allow to save space in the blockchain. Consequently the minimal } ``` +#### Version 2 + +``` +{ + "721": { + "": { + "": { + "name": , + "image": + } + }, + "version": 2 + } +} +``` + ### Retrieve valid metadata for a specific token As mentioned above this metadata structure allows to have either one token or multiple tokens with also different policies in a single mint transaction. A third party tool can then fetch the token metadata seamlessly. It doesn't matter if the metadata includes just one token or multiple. The proceedure for the third party is always the same: @@ -114,8 +139,8 @@ Using the latest mint transaction with the label 721 as valid metadata for a tok ## Backward Compatibility -To keep NFT metadata compatible with changes coming up in the future, we use the **`version`** property. Version `1.0` is used in the current metadata structure of this CIP. -Version `2.0` will introduce [schema.org](https://schema.org). +To keep NFT metadata compatible with changes coming up in the future, we use the **`version`** property. +A future version will introduce [schema.org](https://schema.org). ## References diff --git a/CIP-0025/cddl/version_1.cddl b/CIP-0025/cddl/version_1.cddl new file mode 100644 index 0000000000..551d7368e8 --- /dev/null +++ b/CIP-0025/cddl/version_1.cddl @@ -0,0 +1,24 @@ +string = text .size (0..64) + +policy_id = string +asset_name = string ; utf-8 + +files_details = + { + name : string, + mediaType : string, + src : string / [* string] + } + +metadata_details = + { + name : string, + image : string / [* string], + ? mediaType : string, + ? description : string / [* string], + ? files : [* files_details] + } + +label_metadata = { * policy_id => { * asset_name => metadata_details } } + +metadata = { 721 : uint => label_metadata } \ No newline at end of file diff --git a/CIP-0025/cddl/version_2.cddl b/CIP-0025/cddl/version_2.cddl new file mode 100644 index 0000000000..e26e0a2f34 --- /dev/null +++ b/CIP-0025/cddl/version_2.cddl @@ -0,0 +1,24 @@ +string = text .size (0..64) + +policy_id = bytes ; no longer in text +asset_name = bytes ; no longer in text and utf-8 + +files_details = + { + name : string, + mediaType : string, + src : string / [* string] + } + +metadata_details = + { + name : string, + image : string / [* string], + ? mediaType : string, + ? description : string / [* string], + ? files : [* files_details] + } + +label_metadata = { * policy_id => { * asset_name => metadata_details }, version: 2 } ; version 2 + +metadata = { 721 : uint => label_metadata } \ No newline at end of file