メタデータ

InscriptionにはCBORメタデータを含めることができ、タグ5のフィールドにデータプッシュとして保存されます。データプッシュは520バイトに制限されているため、520バイトを超えるメタデータは複数のタグ5フィールドに分割し、デコード前に連結される必要があります。

メタデータは人間が読める形式で、すべてのメタデータはInscriptionとともにユーザーに表示されます。Inscriptionの作成者は、メタデータがどのように表示されるかを考慮し、簡潔で魅力的なメタデータを作成することが推奨されます。

メタデータは以下のようにHTMLレンダリングされて表示されます:

  • nulltruefalse、数値、浮動小数点数、文字列はプレーンテキストとしてレンダリングされます。
  • バイト文字列は大文字の16進数としてレンダリングされます。
  • 配列は<ul>タグとしてレンダリングされ、各要素は<li>タグで囲まれます。
  • マップは<dl>タグとしてレンダリングされ、各キーは<dt>タグ、各値は<dd>タグで囲まれます。
  • Tags are rendered as the tag , enclosed in a <sup> tag, followed by the value.

CBOR is a complex spec with many different data types, and multiple ways of representing the same data. Exotic data types, such as tags, floats, and bignums, and encoding such as indefinite values, may fail to display correctly or at all. Contributions to ord to remedy this are welcome.

Since CBOR is not human readable, in these examples it is represented as JSON. Keep in mind that this is only for these examples, and JSON metadata will not be displayed correctly.

The metadata {"foo":"bar","baz":[null,true,false,0]} would be included in an inscription as:

OP_FALSE
OP_IF
    ...
    OP_PUSH 0x05 OP_PUSH '{"foo":"bar","baz":[null,true,false,0]}'
    ...
OP_ENDIF

And rendered as:

<dl>
  ...
  <dt>metadata</dt>
  <dd>
    <dl>
      <dt>foo</dt>
      <dd>bar</dd>
      <dt>baz</dt>
      <dd>
        <ul>
          <li>null</li>
          <li>true</li>
          <li>false</li>
          <li>0</li>
        </ul>
      </dd>
    </dl>
  </dd>
  ...
</dl>

Metadata longer than 520 bytes must be split into multiple fields:

OP_FALSE
OP_IF
    ...
    OP_PUSH 0x05 OP_PUSH '{"very":"long","metadata":'
    OP_PUSH 0x05 OP_PUSH '"is","finally":"done"}'
    ...
OP_ENDIF

Which would then be concatenated into {"very":"long","metadata":"is","finally":"done"}.

See examples for on-chain examples of inscriptions that feature this functionality.