A standard encoding and addressing for non-fungible tokens (NFTs) for upholding chain immutablity gurantees off chain.
Following standard defines a standard encoding for ERC-721 Non-Fungible Token assets & metadata (addressed by tokenURI
) which is compatible with the existing specification, while it attempts to address some of the issues found in the wild.
ERC-721: Non-Fungible Token Standard defines tokenURI
as a distinct Uniform Resource Identifier (URI) for a given asset where it may point to a JSON file that conforms to the "ERC721 Metadata JSON Schema".
Metadata schema in turn defines name
, description
and image
string fields, where image
is a URI pointing to a resource with mime type image/*
representing the asset to which this NFT represents.
Loose requirements lead to number of problems in the wild:
- Autheticity - Many NFTs use URIs to web 2.0 host that
- Can go down and make assets inaccessible (404)
- Serve unauthentic resource for maliciously or unintentionally.
- Ambiguity - While specification only defines
image
field for the asset, in practice many new fields with URI are used. This introduces ambiguity in which URIs are part of NFT asset and which are not.
IPNFT specification defines IPLD format for encoding NFT metadata and all the assets into a hash linked DAG which can be addressed via ipfs://
URLs and used in tokenURI
in ERC-721 compatible way while addressing outlined problems as follows:
- Autheticity - Content addressing of IPFS guarantees that content can be retreived from arbitrary nodes in the network and that content is verifiably be authentic.
- Ambiguity - All sssets included in the DAG are part of NFT any URL inside the metadata is not.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
MUST be an IPLD link to DAG-PB directory, which SHOULD contain exactly one named file.
Every IPNFT MUST be DAG-CBOR encoded data structure which MUST have:
type
property with"nft"
value.name
property with a string vaule.description
property with a string value.- Have
image
asset link.
IPFNT data structure MAY contain arbitrary other properties however it is RECOMMENDED to put those under properties
as per "ERC721 Metadata JSON Schema".
All NFT assets MUST be included in IPNFT data structure as asset links which MAY be any top level property except (type
, name
, description
, image
, properties
, metadata.json
) or any nested property.
It is RECOMMENDED for IPNFT to have a metadata.json
IPLD link to a JSON source in DAG-PB or RAW encoding mirroring IPNFT data structure with following caveats:
type
property is OPTIONAL and can be omitted. If present it MUST have value"nft"
.- Asset links MUST be substituted for corresponding
ipfs://{asset_cid}/file.png
URLs in string format (substitutefile.png
with actual file name). - SHOULD NOT have a property named
metadata.json
so it does not diverge from IPNFT data structure.
-
IPNFT root block should not exceed 1MiB in size.
Larger blocks are not well supported by IPFS. If CBOR encoded metadata still exceeds this block limit author shoud consider refatoring metadata into multiple block e.g. taking JSON substructure, encoding it in DAG-CBOR and linking to it from metadata.