# instrumentの情報と表示の決まりを引く

> walletがregistryのmetadataのAPIから、支える標準とinstrumentの情報を取得し、額の桁や止まった状態やaccountの欄を表示にどう使うかを2つの図で追います。

- URL: https://cardene.dev/diagrams/canton-token-instrument-metadata
- 公開日: 2026-11-24
- 更新日: 2026-11-24
- トピック: Blockchain
- タグ: Canton
- 親の図解: [registryのAPI](https://cardene.dev/diagrams/canton-ext-registry-api.md): walletがregistryかScan Proxyから、instrumentの情報とtransferとallocationのchoice contextを受け取る所を、章の中の図解で追います。

この頁では、walletがregistryの台帳の外のAPIから、registryが支える標準とinstrumentの情報を取得する所を追います。
取得した情報のうち、額の桁と止まった状態とaccountの欄は、walletが表示で使う決まりを持ちます。

## registryとinstrumentの語

Token Standardは、送金を含む、トークンの操作のDamlのinterfaceと、台帳の外のAPIの集まりです。
registryは、トークンのinstrumentを管理し、所有の記録を持ち、台帳の上のDamlのinterfaceと、台帳の外のHTTPのAPIを出すアプリです。
instrumentは、registryが管理するトークンの種類で、walletはToken Metadataの台帳の外のAPIから、その表示の名前と記号を得ます。
総供給量は、返る場合があります。

instrumentを管理する側は、instrument adminと呼ばれ、instrumentにidを付けます。
partyは、Damlの台帳とやり取りする物で、userか組織を表します。
accountは、holdingを置く単位で、accountの提供者のaccount providerと、accountの識別子のaccount IDを持ちます。
accountの型は、章「Token StandardのDaml API」の頁「holdingとmetadataの型を知る」が追っています。

https://cardene.dev/diagrams/canton-holding-metadata

HTTPは、WebのAPIが要求と応答をやり取りする通信の決まりです。
この頁のAPIは全てGETで、情報を取り出す要求です。

## 取得するエンドポイントは3つあり2か所に置かれる

registryの情報を取得するエンドポイントは、registryの情報を返すエンドポイントと、instrumentを並べるエンドポイントと、instrumentを1つ取得するエンドポイントの3つです。
この3つは、registryが自ら出す版と、Scan Proxyの版の2か所に置かれます。
Scan Proxy APIは、Scanへの問い合わせを中継するAPIで、validatorのAPIの下の`/v0/scan-proxy/registry/`に、registryと同じAPIを置きます。

| 取得する物 | registryが自ら出す版のパス | Scan Proxyの版のパス |
|---|---|---|
| registryの情報 | `/registry/metadata/v1/info` | `/v0/scan-proxy/registry/metadata/v1/info` |
| instrumentの一覧 | `/registry/metadata/v1/instruments` | `/v0/scan-proxy/registry/metadata/v1/instruments` |
| instrumentの1つ | `/registry/metadata/v1/instruments/:instrumentId` | `/v0/scan-proxy/registry/metadata/v1/instruments/:instrumentId` |

registryが自ら出す版は、Scan Proxyの版と同じく、registryの情報とregistryが支える標準を返します。
一覧と1つを取得するエンドポイントは、どちらの版も0.6.11と0.6.12で変わりました。
一覧は、同じクエリと応答で、instrument adminが管理するinstrumentを全て並べ、応答の`instruments`の配列に入れて返します。
クエリの`pageSize`は`int32`の整数で既定が25、`pageToken`は前の頁の応答の`nextPageToken`です。

## registryが支える標準を知る

registryの情報を返すエンドポイントは、必須の欄を2つ返します。
`adminId`は、registryのアプリを表すDamlのpartyです。
`supportedApis`は、Token StandardのAPIの名前から、サポートするマイナー版への対応で、例は`splice-api-token-metadata-v1`に対して1です。
この1は、マイナー版に当たります。

Token Metadataのエンドポイントは、404と500のエラーで、必須の`error`の欄を返します。

## walletが呼ぶ例

図Aは、walletがregistryの3つのエンドポイントを呼ぶ例です。
一覧の応答に`nextPageToken`がある時だけ、次の頁を取得します。
instrumentを1つ取得するエンドポイントは、一覧とは別に、パスの`instrumentId`が分かる時に呼べます。
この図では、registryが自ら出す版もScan Proxyの版も同じ呼び方なので、1つのregistryの箱で描きます。

```dragon
sequence walletがinstrumentの情報を取得する呼び出し例

box W as wallet [note: 表示する側, color: blue, icon: user]
box R as registryのAPI [note: instrumentの情報を返す, color: rose, icon: server]

step 支える標準を知る
  say walletは、registryの情報を返すエンドポイントを呼び、registryのアプリのpartyと、支えるAPIのマイナー版の対応を受け取ります。
  W -> R: 情報を取得
  R -> W: 支える標準を返す
  source CantonのGET /registry/metadata/v1/info [url: https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1info]

step instrumentを並べる
  say 続いて、instrumentを並べるエンドポイントを呼びます。1頁のinstrumentの数を決めるクエリパラメータのpageSizeは、既定が25です。
  W -> R: 一覧を取得
  R -> W: 1頁分を返す
  source CantonのGET /registry/metadata/v1/instruments [url: https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1instruments]

step 次の頁がある時
  say 応答に任意のnextPageTokenがある時は、それが次の頁のトークンです。walletは、次の要求のクエリパラメータのpageTokenにそのまま渡します。
  W -> R: 次の頁を取得
  R -> W: 次の頁を返す
  source CantonのGET /registry/metadata/v1/instruments [url: https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1instruments]

step IDが分かる時に1つを取得する
  say instrumentのIDが分かる時は、パスの必須のinstrumentIdで指して1つを取得します。このエンドポイントは、一覧とは別に呼べて、応答は、一覧の1件と同じInstrumentの欄を持ちます。
  W -> R: 1つを取得
  R -> W: Instrumentを返す
  source CantonのGET /registry/metadata/v1/instruments/:instrumentId [url: https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1instruments:instrumentid]
```

## Instrumentの欄

図Bは、1件のInstrumentが持つ欄を、役割ごとの枝に分けて追います。
この図では、枝は欄の置き場だけを示し、欄どうしの関係は示しません。
pauseInfoの中のreasonとuntilは、図に置かず、節「止まったinstrumentは動かせない」で書きます。

```dragon
mind Instrumentが持つ欄

step 識別の欄
  say Instrumentの必須のidは、adminが付けた重ならない識別子です。必須のnameとsymbolは、adminが勧める表示の名前と記号で、重なることがあります。
  idea root as "Instrument" [color: slate]
  idea ident as "識別" of root [color: blue]
  idea fid as "id" of ident [color: blue]
  idea fname as "name" of ident [color: blue]
  idea fsym as "symbol" of ident [color: blue]
  source CantonのGET /v0/scan-proxy/registry/metadata/v1/instruments [url: https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1instruments]

step 供給量と桁の欄
  say 任意のtotalSupplyは、返る場合がある、今の総供給量をDecimalで表した文字列です。任意のtotalSupplyAsOfは、その総供給量を最後に計算した時刻です。必須のdecimalsは、小数の桁数です。
  idea supply as "総供給量" of root [color: blue]
  idea ts as "totalSupply" of supply [color: blue]
  idea tsa as "totalSupplyAsOf" of supply [color: blue]
  idea digits as "桁" of root [color: blue]
  idea dec as "decimals" of digits [color: blue]
  source CantonのGET /v0/scan-proxy/registry/metadata/v1/instruments [url: https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1instruments]

step 止まった状態の欄
  say pausedは、instrumentが今止まっているかを示す任意の欄です。pauseInfoも任意で、中のreasonとuntilも任意です。
  idea stop as "止まった状態" of root [color: blue]
  idea fpaused as "paused" of stop [color: blue]
  idea fpi as "pauseInfo" of stop [color: blue]
  source CantonのGET /v0/scan-proxy/registry/metadata/v1/instruments [url: https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1instruments]

step 支える版とaccountの欄
  say 各Instrumentは、必須のsupportedApisも持ち、API名からサポートするマイナー版への対応を示します。showAccountInputFieldsと、それに置き換わったaccountInputFieldsToShowは、任意で、walletの入力のフォームに出すaccountの欄を決めます。
  idea apis as "支える版" of root [color: blue]
  idea fsa as "supportedApis" of apis [color: blue]
  idea acct as "accountの欄" of root [color: blue]
  idea fsh as "showAccountInputFields" of acct [color: blue]
  idea fto as "accountInputFieldsToShow" of acct [color: blue]
  source CantonのGET /v0/scan-proxy/registry/metadata/v1/instruments [url: https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1instruments]
```

## 額の桁は表示に使う

`decimals`は必須の`int8`の整数で、既定は10です。
値は0から10の間と決まっていて、理由は、Damlのinterfaceが保有の額を、小数10桁で38桁まで正確な`Decimal`で表すためです。
0にすると、instrumentは整数の単位でしか持てません。

`Decimal`は、小数点の前に28桁、後に10桁を持つ固定小数点の数です。
walletは、額を表示し入力を受ける時の小数の桁数を、`decimals`で決めるよう勧められています。

## 止まったinstrumentは動かせない

`paused`は任意で、既定がfalseで、instrumentが今止まっているかを示します。
止まったinstrumentは、transferもallocateもできません。
transferとallocationの文脈は、この章の次の2頁で追います。

`pauseInfo`は任意で、中の`reason`と`until`も、どちらも任意です。
`reason`は止めた理由で、`until`は分かる場合の止める期限です。
`until`の時刻は、止める期間に含まれません。

## accountの欄は、walletのフォームに出す

`showAccountInputFields`は、既定がfalseで、instrumentが基本でないaccountを支えるので、walletがtransferとallocationの入力のフォームに、account providerとaccount IDの欄を出すべきかを示します。
この欄は、より細かい`accountInputFieldsToShow`に置き換わり、非推奨になりました。

`accountInputFieldsToShow`は任意で、walletがフォームに出すaccountの入力の欄を示し、例は`provider`です。
walletは、transferとallocationを表示する時、`null`でないaccount providerとaccount IDを必ず表示するよう勧められています。

## 次に読む頁

次の頁「transferの文脈を受け取る」は、transfer instructionをaccept、reject、withdrawする前と、直接のtransferの前に、registryかScan Proxyから、factoryとchoice contextとtransferの種類をどう受け取るかを追います。

https://cardene.dev/diagrams/canton-transfer-choice-context

## 出典

https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1info

https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1instruments

https://docs.canton.network/reference/splice-token-metadata-service/get-registrymetadatav1instruments:instrumentid

https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1info

https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1instruments

https://docs.canton.network/reference/splice-scan-proxy-token-metadata-service/get-v0scan-proxyregistrymetadatav1instruments:instrumentid
