Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIP-0025: Added version 2 and cddl #267

Merged
merged 7 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions CIP-0025/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -50,7 +50,7 @@ The structure allows for multiple token mints, also with different policies, in
"name": <string>,

"image": <uri | array>,
"mediaType": "image/<mime_sub_type>",
"mediaType": image/<mime_sub_type>,

"description": <string | array>,

Expand All @@ -64,27 +64,36 @@ The structure allows for multiple token mints, also with different policies, in
<other properties>
}
},
"version": "1.0"
"version": <version_id>
}
}
```

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.<br /> **`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.<br /> **`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": {
Expand All @@ -98,6 +107,22 @@ Optional fields allow to save space in the blockchain. Consequently the minimal
}
```

#### Version 2

```
{
"721": {
"<policy_id>": {
"<asset_name>": {
"name": <string>,
"image": <uri | array>
}
},
"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:
Expand All @@ -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

Expand Down
24 changes: 24 additions & 0 deletions CIP-0025/cddl/version_1.cddl
Original file line number Diff line number Diff line change
@@ -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 }
24 changes: 24 additions & 0 deletions CIP-0025/cddl/version_2.cddl
Original file line number Diff line number Diff line change
@@ -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 }