diff --git a/ERCS/erc-7280.md b/ERCS/erc-7280.md new file mode 100644 index 0000000000..d736d2e9be --- /dev/null +++ b/ERCS/erc-7280.md @@ -0,0 +1,124 @@ +--- +eip: 7280 +title: NFT Metadata Extension like JSON-LD +description: Let NFT metadata have a feature equivalent to JSON-LD to be semantic. +author: Yohei Nishikubo (@yoheinishikubo) +discussions-to: https://ethereum-magicians.org/t/eip-7280-nft-metadata-extension-like-json-ld/14935 +status: Draft +type: Standards Track +category: ERC +created: 2023-07-04 +requires: 721, 1155, 3525 +--- + +## Abstract + +This proposal expands the metadata format for Non-Fungible Tokens ([ERC-721](./eip-721.md), [ERC-1155](./eip-1155.md), [ERC-3525](./eip-3525.md), and others), adding support for linked data like JSON-LD format. The additional data is stored under the linked_data key in the metadata JSON. + +## Motivation + +The existing metadata format for Non-Fungible Tokens is limited and doesn't support the inclusion of structured and semantically meaningful data. By integrating JSON-LD (Linked Data), we can enhance the richness and interoperability of the metadata associated with NFTs. + +This allows for complex metadata structures that can link to external schemas and data, improving the contextual relevance and usability of NFTs across various applications. + +## Specification + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. + +The JSON-LD based metadata is stored under a new `linked_data` key in the metadata JSON. The `linked_data` key is an array of objects, where each object contains two keys: `schema` and `data`. + +| name | compliance level | type | description | +| ------ | ---------------- | ------ | ------------------------------ | +| schema | MUST | object | The schema of the linked data. | +| data | MUST | object | The data of the linked data. | + +### Schema + +| name | compliance level | type | description | +| ----------- | ---------------- | ------ | ------------------------------ | +| uri | MUST | string | The URI of the schema. | +| name | MUST | string | The name of the schema. | +| description | OPTIONAL | string | The description of the schema. | + +### Data + +| name | compliance level | type | description | +| ----------- | ---------------- | ------ | --------------------------------------------------------- | +| uri | MUST | string | The URI of the data. | +| lang | OPTIONAL | string | The language of the data. IETF language tag like `en-US`. | +| name | OPTIONAL | string | The name of the data. | +| description | OPTIONAL | string | The description of the data. | + +## Rationale + +For providing typical webpage for an NFT, it's much simple to include JSON-LD in HTML header tag with this extension. Just looking for JSON-LD compliant value's uri from `linked_data` array, fetch it and embed its content in HTML header tag. +This means the minter of NFT can control the appearance in the search result of Google, for example. +In more common case for interoperability, the NFT metadata can include any schema and data with this extension. This means the NFT metadata can be used as a data source for any application. With the schema, the implementation is much easier. + +## Backwards Compatibility + +The proposed expansion to the NFT metadata format is backward compatible with existing implementations. NFTs that do not include the `linked_data` key will continue to function as before, and existing applications consuming NFT metadata will not be affected. + +## Reference Implementation + +Here is an example metadata JSON demonstrating the new linked_data structure: + +```json +{ + "name": "NFT Name", + "description": "This NFT represents...", + "image": "https://example.org/images/nft.png", + "linked_data": [ + { + "schema": { + "name": "VideoObject", + "uri": "https://example.org/schemas/VideoObject.json" + }, + "data": { + "uri": "https://example.org/data/video1.json" + } + }, + { + "schema": { + "name": "MusicRecording", + "uri": "https://example.org/schemas/MusicRecording.json" + }, + "data": { + "uri": "https://example.org/data/music1.json" + } + }, + { + "schema": { + "name": "GoogleTravelImpactModel", + "uri": "https://example.org/schemas/GoogleTravelImpactModel.json" + }, + "data": { + "uri": "https://example.org/data/gtim1.json" + } + } + ] +} +``` + +In the example above, the NFT metadata contains three linked data objects, each with a different schema and data: +First one. VideoObject data can be used as JSON-LD in HTML header tag and realize rich snippet in Google search result. +Second one. MusicRecording data is based on a schema from `schema.org`. However this one cannot realize rich snippet. +Third one. GoogleTravelImpactModel data is a dedicated schema for Google Travel Impact Model. +The most important point is that any schema and data can be included with this standard like above. + +### Sample files + +- [VideoObject.json](../assets/eip-7280/samples/schemas/VideoObject.json) +- [MusicRecording.json](../assets/eip-7280/samples/schemas/MusicRecording.json) +- [GoogleTravelImpactModel.json](../assets/eip-7280/samples/schemas/GoogleTravelImpactModel.json) +- [video1.json](../assets/eip-7280/samples/data/video1.json) +- [music1.json](../assets/eip-7280/samples/data/music1.json) +- [gtim1.json](../assets/eip-7280/samples/data/gtim1.json) + +## Security Considerations + +The proposed expansion does not introduce any additional security considerations beyond those already associated with NFTs and linked data. Implementations should adhere to best practices for secure handling and validation of metadata from external sources. + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE.md). diff --git a/assets/erc-7280/samples/data/gtim1.json b/assets/erc-7280/samples/data/gtim1.json new file mode 100644 index 0000000000..7e80e49218 --- /dev/null +++ b/assets/erc-7280/samples/data/gtim1.json @@ -0,0 +1,67 @@ +{ + "flightEmissions": [ + { + "flight": { + "origin": "ZRH", + "destination": "CDG", + "operatingCarrierCode": "AF", + "flightNumber": 1115, + "departureDate": { + "year": 2024, + "month": 6, + "day": 1 + } + }, + "emissionsGramsPerPax": { + "first": 92137, + "business": 92137, + "premiumEconomy": 61425, + "economy": 61425 + } + }, + { + "flight": { + "origin": "CDG", + "destination": "BOS", + "operatingCarrierCode": "AF", + "flightNumber": 334, + "departureDate": { + "year": 2024, + "month": 6 + "day": 1 + } + }, + "emissionsGramsPerPax": { + "first": 1384120, + "business": 1107296, + "premiumEconomy": 415236, + "economy": 276824 + } + }, + { + "flight": { + "origin": "ZRH", + "destination": "BOS", + "operatingCarrierCode": "LX", + "flightNumber": 52, + "departureDate": { + "year": 2024, + "month": 5, + "day": 1 + } + }, + "emissionsGramsPerPax": { + "first": 1887615, + "business": 1510092, + "premiumEconomy": 566284, + "economy": 377523 + } + } + ], + "modelVersion": { + "major": 1, + "minor": 7, + "patch": 0, + "dated": "20230817" + } +} \ No newline at end of file diff --git a/assets/erc-7280/samples/data/music1.json b/assets/erc-7280/samples/data/music1.json new file mode 100644 index 0000000000..c00a62d65c --- /dev/null +++ b/assets/erc-7280/samples/data/music1.json @@ -0,0 +1,95 @@ +{ + "@context": "https://schema.org/", + "@type": "MusicRecording", + "name": "Cupid", + "byArtist": { + "@type": "MusicGroup", + "name": "Fifty Fifty", + "memberOf": [ + { + "@type": "Person", + "name": "Aran" + }, + { + "@type": "Person", + "name": "Keena" + }, + { + "@type": "Person", + "name": "Saena" + }, + { + "@type": "Person", + "name": "Sio" + } + ] + }, + "datePublished": "2023-02-24", + "inLanguage": "Korean", + "producer": { + "@type": "Person", + "name": "Siahn" + }, + "recordLabel": { + "@type": "Organization", + "name": "Attrakt", + "foundingDate": "2021", + "location": { + "@type": "Country", + "name": "South Korea" + } + }, + "recordingOf": { + "@type": "MusicComposition", + "composer": [ + { + "@type": "Person", + "name": "Adam von Mentzer" + }, + { + "@type": "Person", + "name": "Mac Felländer-Tsai" + }, + { + "@type": "Person", + "name": "Louise Udin" + } + ], + "lyricist": [ + { + "@type": "Person", + "name": "Keena" + }, + { + "@type": "Person", + "name": "Ahin" + } + ], + "musicArrangement": [ + { + "@type": "Person", + "name": "Adam von Mentzer" + }, + { + "@type": "Person", + "name": "Mac Felländer-Tsai" + }, + { + "@type": "Person", + "name": "Louise Udin" + } + ], + "timeRequired": "PT3M", + "inLanguage": "Korean", + "description": "Its lyrics describe a young woman's unrequited crush and her feeling dumb for falling in love. In the song's chorus, the group sings, 'I gave a second chance to Cupid/I believed you, I'm so stupid/Let me show you, my secret love, is it real?/Cupid is so dumb.' The group harmonizes on the song, while the latter half of the song includes a key change and a rap verse performed by Keena. The instrumental features synths and guitars." + }, + "duration": "PT3M", + "genre": "K-pop, Disco-pop, Synth-pop, Bubblegum", + "inAlbum": { + "@type": "MusicAlbum", + "name": "The Beginning: Cupid", + "datePublished": "2023-02-24" + }, + "position": "1", + "description": "\"Cupid\" is a single by South Korean girl group Fifty Fifty, released on February 24, 2023. The song achieved significant international success, charting in numerous countries including the United States." +} diff --git a/assets/erc-7280/samples/data/video1.json b/assets/erc-7280/samples/data/video1.json new file mode 100644 index 0000000000..0dc0eceb47 --- /dev/null +++ b/assets/erc-7280/samples/data/video1.json @@ -0,0 +1,17 @@ +{ + "@context": "http://schema.org", + "@type": "VideoObject", + "name": "FIFTY FIFTY (피프티피프티) - 'Cupid' Official MV", + "description": "The video is a song lyrics expressing feelings of loneliness and longing for love. The speaker questions why they are feeling lonely and desires to be held and loved. They mention giving Cupid a second chance and feeling foolish for believing in love. The speaker practices love in their dreams and wants someone to share their feelings with. They express their willingness to wait and not give up on love. The text ends with the speaker calling themselves a fool for love and giving Cupid another chance despite feeling stupid. The text suggests that Cupid is not intelligent and is giving the reader one final opportunity.", + "thumbnailUrl": "https://i.ytimg.com/vi/Qc7_zRjH808/maxresdefault.jpg", + "uploadDate": "2023-02-23T13:00:10Z", + "duration": "PT3M23S", + "contentUrl": "https://www.youtube.com/watch?v=Qc7_zRjH808", + "embedUrl": "https://www.youtube.com/embed/Qc7_zRjH808", + "interactionStatistic": { + "@type": "InteractionCounter", + "userInteractionCount": "100219440" + }, + "commentCount": "76810", + "regionsAllowed": "Worldwide" +} diff --git a/assets/erc-7280/samples/schemas/GoogleTravelImpactModel.json b/assets/erc-7280/samples/schemas/GoogleTravelImpactModel.json new file mode 100644 index 0000000000..6bd5353916 --- /dev/null +++ b/assets/erc-7280/samples/schemas/GoogleTravelImpactModel.json @@ -0,0 +1,91 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "flightEmissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "flight": { + "type": "object", + "properties": { + "origin": { + "type": "string" + }, + "destination": { + "type": "string" + }, + "operatingCarrierCode": { + "type": "string" + }, + "flightNumber": { + "type": "integer" + }, + "departureDate": { + "type": "object", + "properties": { + "year": { + "type": "integer" + }, + "month": { + "type": "integer" + }, + "day": { + "type": "integer" + } + }, + "required": ["year", "month", "day"] + } + }, + "required": [ + "origin", + "destination", + "operatingCarrierCode", + "flightNumber", + "departureDate" + ] + }, + "emissionsGramsPerPax": { + "type": "object", + "properties": { + "first": { + "type": "integer" + }, + "business": { + "type": "integer" + }, + "premiumEconomy": { + "type": "integer" + }, + "economy": { + "type": "integer" + } + }, + "required": ["first", "business", "premiumEconomy", "economy"] + } + }, + "required": ["flight", "emissionsGramsPerPax"] + } + }, + "modelVersion": { + "type": "object", + "properties": { + "major": { + "type": "integer" + }, + "minor": { + "type": "integer" + }, + "patch": { + "type": "integer" + }, + "dated": { + "type": "string" + } + }, + "required": ["major", "minor", "patch", "dated"] + } + }, + "required": ["flightEmissions", "modelVersion"] +} diff --git a/assets/erc-7280/samples/schemas/MusicRecording.json b/assets/erc-7280/samples/schemas/MusicRecording.json new file mode 100644 index 0000000000..3a9d7e2d68 --- /dev/null +++ b/assets/erc-7280/samples/schemas/MusicRecording.json @@ -0,0 +1,82 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MusicRecording", + "type": "object", + "properties": { + "byArtist": { + "oneOf": [ + { "$ref": "#/definitions/MusicGroup" }, + { "$ref": "#/definitions/Person" } + ], + "description": "The artist that performed this album or recording." + }, + "duration": { + "type": "string", + "description": "The duration of the item (movie, audio recording, event, etc.) in ISO 8601 date format." + }, + "inAlbum": { + "$ref": "#/definitions/MusicAlbum", + "description": "The album to which this recording belongs." + }, + "inPlaylist": { + "$ref": "#/definitions/MusicPlaylist", + "description": "The playlist to which this recording belongs." + }, + "isrcCode": { + "type": "string", + "description": "The International Standard Recording Code for the recording." + }, + "recordingOf": { + "$ref": "#/definitions/MusicComposition", + "description": "The composition this track is a recording of." + } + }, + "definitions": { + "MusicGroup": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "genre": { "type": "string" }, + "members": { + "type": "array", + "items": { "$ref": "#/definitions/Person" } + } + } + }, + "Person": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "birthDate": { "type": "string", "format": "date" }, + "nationality": { "type": "string" } + } + }, + "MusicAlbum": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "releaseDate": { "type": "string", "format": "date" }, + "byArtist": { "$ref": "#/definitions/MusicGroup" } + } + }, + "MusicPlaylist": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "numberOfTracks": { "type": "integer" }, + "tracks": { + "type": "array", + "items": { "$ref": "#/definitions/MusicRecording" } + } + } + }, + "MusicComposition": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "composer": { "$ref": "#/definitions/Person" }, + "dateComposed": { "type": "string", "format": "date" } + } + } + } +} diff --git a/assets/erc-7280/samples/schemas/VideoObject.json b/assets/erc-7280/samples/schemas/VideoObject.json new file mode 100644 index 0000000000..4a81e874b2 --- /dev/null +++ b/assets/erc-7280/samples/schemas/VideoObject.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "VideoObject", + "type": "object", + "properties": { + "actor": { + "type": "string", + "description": "An actor, e.g. in TV, radio, movie, video games etc., or in an event. Actors can be associated with individual items or with a series, episode, clip." + }, + "caption": { + "type": "string", + "description": "The caption for this object. For downloadable machine formats (closed caption, subtitles etc.) use MediaObject and indicate the encodingFormat." + }, + "director": { + "type": "string", + "description": "A director of e.g. TV, radio, movie, video gaming etc. content, or of an event. Directors can be associated with individual items or with a series, episode, clip." + }, + "embeddedTextCaption": { + "type": "string", + "description": "Represents textual captioning from a MediaObject, e.g. text of a 'meme'." + }, + "musicBy": { + "type": "string", + "description": "The composer of the soundtrack." + }, + "transcript": { + "type": "string", + "description": "If this MediaObject is an AudioObject or VideoObject, the transcript of that object." + }, + "videoFrameSize": { + "type": "string", + "description": "The frame size of the video." + }, + "videoQuality": { + "type": "string", + "description": "The quality of the video." + } + }, + "required": [ + "actor", + "caption", + "director", + "embeddedTextCaption", + "musicBy", + "transcript", + "videoFrameSize", + "videoQuality" + ] +}