dfinity / ICRC

Repository to ICRC proposals
Apache License 2.0
26 stars 5 forks source link

Reserved For Large Metadata Handling in Transaction Logs #61

Open skilesare opened 4 months ago

skilesare commented 4 months ago

We have identified that icrc1_supported_standards needs to be generalized into its own ICRC.

skilesare commented 3 months ago

We may need to provide a hash or URL in block data so that large metadata can be reconstructed. This ICRC-61 number will be used for defining that standard.

skilesare commented 1 day ago

To provide a standardized approach to handling metadata that is too large to fit inside of a standard ICRC-3 Value block, ICRC-61 defines the standard structure and expected behavior for consumers of the Block. The initial standards are purposely simple and MAY be extended through additional ICRC Extensions to target specific systems, standards, and protocols. Below is a comprehensive description of the ICRC-61 External Metadata Standard's specifications.

Behavior:

When a parser encounters a Map variant in a Value type that has a key that contains one or more of the following icrc61_{} keys, the parser should retrieve the file, parse the path if provided and replace the Map in the tree with a Value containing the retrieved data

A Text variant should be used for the retrieved data and the data should be represented as a dataURI. The mime type used can be overridden with the icrc61_mime key in the ICRC-61 map, otherwise, the mime-type returned from the remote server should be used.

SHA-256 should be the default hashing used if not alternative hash is provided in icrc61_hash_algo. The current standard does not define any other hashing algorithms to use at the is time.

The SHA-256 is supplied in icrc61_hash to validate the retrieved file if provided.

The standard does not explicitly define the names of all possible hash algorithms. Users SHOULD default to the names as defined in ISO and NIST standards.

Data Types

The ICRC-61 standard is agnostic to the data type that an ICRC-61 entry may point to.

The possible values in an ICRC-61 map are as follows.

Map {
   icrc61_url?: Text; // Optional Path to external file. This item MUST exist unless the hash provided is compatible with IPFS
   icrc61_hash?: Text; '8o3vfuaowrgva' // Optional  hash of external file in Base64
   icrc61_hash_algo?: Text; //Optional: Defaults to SHA-256, but user may override the hash function
   icrc61_path?: Text // Optional path to be applied to the retrieved data. Example for JSON: 'a.c.[2].d' json value within above json
   icrc61_mime?: Text; //Optional: override the mime type of the retrieved file
};

Examples

The following Block:

#Map[
  ("btype",  #Text("60upload")),
  ("tx", #Map[
    ("file", #Map[
      ("icrc61_url", #Text("https://foo.bar/data.json"),
      ("icrc61_hash, #Text("UNhYo7NpAQ61sEpPbHXH4B5C4tLwF87qNaAg17Qn8Jw=")),
     ]),
    ("ts", #Nat(1739394848859))
])
]

Would be parsed to:

#Map[
  ("btype",  #Text("60upload")),
  ("tx", #Map[
    ("file", #Text("data:application/json;charset=utf-8;base64,ew0KICAiZm9vIjoiYmFyIiwNCiAgImZpenoiOiJidXp6Ig0KfQ==)"),
    ("ts", #Nat(1739394848859))
])
]