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

SIP-016 Metadata for Tokens #44

Merged
merged 32 commits into from
Aug 26, 2022
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
67cfed9
[WIP] initial draft
friedger Oct 20, 2021
e0317e1
fix metadata spelling, add $schema, require 'version', 'name', 'image'
friedger Oct 23, 2021
680f175
add comment about length of string values
friedger Oct 23, 2021
1cd310c
generalize for any metadata function
friedger Oct 23, 2021
88114b2
clarify activation rule, fix table
friedger Oct 23, 2021
ab2cb46
add properties.id
friedger Oct 23, 2021
7fcd7ea
fix table
friedger Oct 23, 2021
5baa404
improve attributes
friedger Oct 23, 2021
0115927
add properties section
friedger Oct 23, 2021
c53ec7b
Update sip-x-nft-metadata.md
friedger Nov 7, 2021
661ba2a
Update sip-x-nft-metadata.md
friedger Nov 8, 2021
5c82e00
add ip_document_uri as property
friedger Nov 8, 2021
bc2ba1e
add raw_media_file properties
friedger Nov 15, 2021
02e85fb
add valid uri schema, more properties, remove requirement for image, …
friedger Nov 19, 2021
fff7f9a
add more related work
friedger Nov 19, 2021
2bc81e9
fix typo
friedger Nov 19, 2021
b7abada
add seed, remove collection_size
friedger Nov 22, 2021
9194130
Update sip-x-nft-metadata.md
friedger Dec 2, 2021
96662ef
set sip number to 16
friedger Dec 6, 2021
37116cd
Update sip-016-token-metadata.md
friedger Dec 12, 2021
a6e086a
add dant as author, fix formatting
friedger Jan 11, 2022
f3905f8
fix typos, replace `version` with `sip`
friedger Feb 2, 2022
c27bd72
rewrap at col 80
friedger Mar 7, 2022
04a881f
address Jude's comments
friedger Mar 7, 2022
9b243cd
clarify required properties of attributes
friedger Mar 10, 2022
e36a46f
fix translation
friedger Mar 21, 2022
c10e9a3
add sign-off by Jude
friedger Mar 21, 2022
642c0ed
Update sip-016-token-metadata.md
friedger Apr 22, 2022
2c22148
Update sip-016-token-metadata.md
friedger Apr 22, 2022
347ad57
Update sip-016-token-metadata.md
friedger Apr 22, 2022
7941a3c
Change status to Activation-in-Progress
friedger Jun 9, 2022
92b6526
Move to Ratified
friedger Aug 26, 2022
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
163 changes: 163 additions & 0 deletions sips/sip-x/sip-x-nft-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Preamble

SIP Number: X

Title: Schema Definition for Metadata for Non-Fungible Tokens

Author: Friedger Müffke ([email protected])

Consideration: Technical

Type: Standard

Status: Draft

Created: 20 October 2021

License: CC0-1.0

Sign-off:

# Abstract

Non-fungible tokens or NFTs for short are digital assets registered on blockchain with unique identifiers and properties that distinguish them from each other. SIP-009 defines the trait how ownership of an NFT is managed. This SIP aims to provide a flexible standard to attach meta data to NFTs, like descriptions or urls to digital files.
friedger marked this conversation as resolved.
Show resolved Hide resolved

# License and Copyright

This SIP is made available under the terms of the Creative Commons CC0 1.0 Universal license, available at https://creativecommons.org/publicdomain/zero/1.0/
This SIP’s copyright is held by the Stacks Open Internet Foundation.

# Introduction

Tokens are digital assets registered on blockchain through a smart contract. A non-fungible token (NFT) is a token that is globally unique and can be identified through its unique identifier. In blockchains with smart contracts, including the Stacks blockchain, developers and users can use smart contracts to register and interact with non-fungible tokens.

Some use cases of NFTs are name registration, digital art, certification, media and enternainment, real-estate. They all require that users associate certain content with an NFT. In general, it is helpful for the users to have a name, sound, image that represents this content.
friedger marked this conversation as resolved.
Show resolved Hide resolved

# Specification

Every SIP-X compliant smart contract in Stacks blockchain must be SIP-009 compliant and must meet the following requirements for the return value of function `get-token-uri`:

## Return Value of `get-token-uri`

The return value must be a `some` value if and only if the provided parameter `id` is the key of an NFT that was minted and not burnt, otherwise the value must be `none`.

For minted and not burnt NFTs, the inner value of the return value must be a string representing a resolvable URI. For string containing `{id}`, the `{id}` part must be replaced by the id in decimal format given in the function call.

The resolved data must be a JSON blob.

## JSON scheme of Metadata

The JSON blob resolved through the token uri must follow the following JSON schema. If the string `{id}` exists in any JSON value, it MUST be replaced with the actual token id in decimal format, by all client software that follows this standard.

```
{
"title": "Token Metadata",
friedger marked this conversation as resolved.
Show resolved Hide resolved
"type": "object",
"required": [],
friedger marked this conversation as resolved.
Show resolved Hide resolved
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this token represents"
friedger marked this conversation as resolved.
Show resolved Hide resolved
},
"description": {
"type": "string",
"description": "Describes the asset to which this token represents"
},
friedger marked this conversation as resolved.
Show resolved Hide resolved
"image": {
"type": "string",
"description": "A URI pointing to a resource with mime type image/* representing the asset to which this token represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
},
"attributes": {
"type": "array",
"description": "Arbitrary NFT attributes. Values may be strings, numbers, object or arrays."
"items: {
"type": "object",
"properties": {
"display_type": "string",
"trait_type": "string",
"value": {"not": {"type": "object"}},
}
}
},
"properties": {
"type": "object",
"description": "Arbitrary properties. Values may be strings, numbers, object or arrays."
},
"localization": {
"type": "object",
"required": ["uri", "default", "locales"],
"properties": {
"uri": {
"type": "string",
"description": "The URI pattern to fetch localized data from. This URI should contain the substring `{locale}` which will be replaced with the appropriate locale value before sending the request."
},
"default": {
"type": "string",
"description": "The locale of the default data within the base JSON"
},
"locales": {
"type": "array",
"description": "The list of locales for which data is available. These locales should conform to those defined in the Unicode Common Locale Data Repository (http://cldr.unicode.org/)."
}
}
}
}
}
```

### Examples

# Using NFTs in applications

Before presenting metadata to users, application developers should verify whether the metadata is compliant with the applications guidelines.
friedger marked this conversation as resolved.
Show resolved Hide resolved

We remind implementation authors that the empty string for the token uri is a valid response. We also remind everyone that any smart contract can use the same metadata as other NFT contracts. It is out of the scope of this standard to define how a client may determine which smart contracts are is the original, well-known, canonical one.

Furthermore, accessiblity of content is not covered by the standard.

Note, that metadata might change over time.

# Related Work

NFTs are an established asset class on blockchains. Read for example [here](https://www.ledger.com/academy/what-are-nft).

## BNS

The Blockchain Naming System uses native non-fungible tokens. It does define metadata for a name through attachements. The schema for names owned by a person follows the definition of (schema.org/Person)[https://schema.org/Person]. This could be an alternative to token URIs.

## EIP 721 and 1155

Metadata for NFTs on Ethereum are defined in [EIP 721](https://eips.ethereum.org/EIPS/eip-721) and [EIP 1155](https://eips.ethereum.org/EIPS/eip-1155). The JSON schema for SIP-X has adopted the EIP 1155 schema with the following differences:

* substitution of `{id}` strings must use the decimal format not the hexdecimal, zero-padded format.

# Backwards Compatibility

## Meta data functions
friedger marked this conversation as resolved.
Show resolved Hide resolved

Some contracts have dedicated functions to provide metadata.

### Boom

The [NFT contract for Boom](https://explorer.stacks.co/txid/0x423d113e14791f5d60f5efbee19bbb05cf5e68d84bcec4e611f2c783b08d05aa?chain=mainnet) implements a variation of this trait using similar naming, but returning other types than response types.

The function signatures for metadata are:

- `(get-boom-meta () {uri: (string-ascii 35), name: (string-ascii 16), mime-type: (string-ascii 9)})` and
- `(get-meta? uint {series-id: uint, number: uint, name: (string-utf8 80), uri: (string-ascii 2048), mime-type: (string-ascii 129), hash: (buff 64)})`

### Badges

The [badges contract](https://explorer.stacks.co/txid/0xb874ddbb4a602c22bb5647c7a2f8bfcafbbca7c0c663a175f2270ef3665f33de?chain=mainnet) defines metadata for nfts.

The function signatures for metadata are:

- `(get-badge-meta () {uri: (string-ascii 78111)})` and
- `(get-meta? (uint) (optional {user: principal}))`

### Beeple


# Activation

This SIP is activated if 5 contracts are deployed that use the same trait that follows this specification. This must happen before Bitcoin tip #750,000.