# burnとmintと変化を記録する

> registryがholdingのburnとmintを汎用の形でどう出し、instrumentのadminがholdingの変化をイベントとしてどう報告するかを、2つの図で追います。

- URL: https://cardene.dev/diagrams/canton-burn-mint-events
- 公開日: 2026-11-24
- 更新日: 2026-11-24
- トピック: Blockchain
- タグ: Canton
- 親の図解: [Token StandardのDaml API](https://cardene.dev/diagrams/canton-ext-token-standard.md): 外のwalletやアプリが資産を扱うためのToken StandardのDaml APIを、送金の手順から、packageの並び、型、送金の指示、記録、Amuletの実装まで、章の中の図解で追います。

前の頁では、walletがregistryにholdingのtransferを指示するchoiceと、transfer instructionの進み方を見ました。
この頁では、registryがburnとmintの操作を汎用の形で出す`Splice.Api.Token.BurnMintV1`と、instrumentのadminがholdingの変化をイベントとして報告する`Splice.Api.Token.TransferEventsV2`を追います。
外のwalletやbridgeが、burnとmintとholdingの変化を読む時に、どのchoiceと欄を見るかを決める材料にします。

https://cardene.dev/diagrams/canton-transfer-instruction

burnは、holdingを消費して無効にする操作で、mintは、新しいholdingを作る操作です。
archiveは、コントラクトを消費して無効にする操作を指し、この頁のburnでは、入力のholdingのarchiveがburnに当たります。
Canton Coinのburnは、頁「Canton Coinの役と料金を知る」で見ました。
bridgeは、別のブロックチェーンと資産を行き来させる仕組みです。

https://cardene.dev/diagrams/canton-coin-tokenomics

## burnとmintを汎用の形で出す

`BurnMintV1`のmoduleは、registryがburnとmintの操作を汎用の形で出し、bridgeがそれを使い、walletがその使われ方を読めるようにするinterfaceです。
interfaceの`BurnMintFactory`は、汎用のburnとmintの操作のfactoryで、実装するtemplateのsignatoryがcontrollerのchoiceの`Archive`を持ちます。

choiceは、`BurnMintFactory_BurnMint`と`BurnMintFactory_PublicFetch`の2つです。
`BurnMintFactory_BurnMint`は、`inputHoldingCids`のholdingをburnし、`outputs`に指定した所有者と量のholdingを作り、`BurnMintFactory_BurnMintResult`を返します。
`BurnMintFactory_PublicFetch`は、データを読むparty`actor`がcontrollerで、`expectedAdmin`と`actor`を受け取り、`BurnMintFactoryView`を返します。

実装は、`expectedAdmin`がfactoryのadminと一致することを、両方のchoiceで必ず確かめます。
呼ぶ側は、自分のParticipant Nodeへの読み取りのような、信頼できる取得元から`expectedAdmin`を得るべきとされています。

`BurnMintFactory_BurnMint`は、6つの欄を受け取ります。

| 欄 | 内容 |
|---|---|
| `expectedAdmin` | 期待するadmin。factoryのadminと一致することを実装が確かめる |
| `instrumentId` | burnとmintの対象のinstrument |
| `inputHoldingCids` | burnするholding |
| `outputs` | 作るholdingの指定 |
| `extraActors` | adminのほかに認可するactor |
| `extraArgs` | 追加の引数とmetadata |

このchoiceは、adminと`extraActors`が共同で認可し、必要なactorの全体は、adminと`extraActors`です。
adminがこのchoiceの全ての呼び出しを制御し、実装によっては、mintとburnするholdingの所有者を`extraActors`に求めます。
多くの場合、`extraActors`は入力と出力の所有者ですが、認可の仕組みの違うトークンの実装を支えるため、別のactorの組も許されます。

実装は、このchoiceの中身を自由に制限できます。
全ての入力で失敗させることも、このinterfaceを実装しないこともできます。

## burnとmintが守る事

`inputHoldingCids`の全てのholdingと、結果の出力のholdingは、`instrumentId`のinstrument IDを持ちます。
このchoiceは、`inputHoldingCids`の全てのholdingをarchiveします。
実装は、全ての入力が同じ所有者に属するなどの追加の制限を課してもかまいません。
このchoiceは、`outputs`に指定した量で、新しいholdingを作ります。

実装は、`extraArgs`のmetadataにkeyの`splice.lfdecentralizedtrust.org/reason`を入れ、このchoiceを呼んだ理由を人が読める形で示すべきとされています。
汎用のwalletが、利用者に理由を見せられるようにするためです。

`BurnMintOutput`は、burnとmintの操作で作るholdingの指定です。

| 欄 | 内容 |
|---|---|
| `owner` | 作るholdingの所有者 |
| `amount` | 量 |
| `context` | ロックなどのregistryごとの機能を支えるのに使える、この出力の`ChoiceContext` |

`BurnMintFactory_BurnMintResult`は、choiceが作ったholdingのIDの一覧の`outputCids`を持ちます。
`outputCids`は、choiceの引数に指定した出力を、ちょうど同じ順で含みます。

`BurnMintFactoryView`は、このburnとmintのfactoryを使えるinstrumentを管理するregistryのアプリを表す`admin`と、拡張のための`meta`を持ちます。
実装は、methodの`burnMintFactory_burnMintImpl`と`burnMintFactory_publicFetchImpl`で、choiceの中身を与えます。

下の図は、burnとmintのchoiceを、adminとfactoryと`extraActors`の3者で追います。
adminの呼び出しの前に、adminと`extraActors`の共同の認可が要ります。

```dragon
sequence burnとmintのchoiceを実行する

box A as registryのadmin [note: 全ての呼び出しを制御する, color: blue, icon: user]
box F as burnとmintのfactory [note: holdingを消費して作る, color: slate, icon: layers]
box X as 追加のactor [note: 多くは入力と出力の所有者, color: rose, icon: user]

step 共同の認可
  say このchoiceは、adminと追加のactorが共同で認可してから呼びます。
  act X: adminと共同で認可する
  source Splice.Api.Token.BurnMintV1 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-burn-mint-v1/splice-api-token-burnmintv1]

step adminが呼ぶ
  say registryのadminは、burnするholdingと、作るholdingの所有者と量を指定して、choiceを呼びます。
  A -> F: burnとmintを呼ぶ
  source Splice.Api.Token.BurnMintV1 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-burn-mint-v1/splice-api-token-burnmintv1]

step 入力を無効にして出力を作る
  say choiceは、入力の全てのholdingをarchiveして無効にし、出力に指定した量で新しいholdingを作ります。
  act F: 入力を無効にして出力を作る
  source Splice.Api.Token.BurnMintV1 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-burn-mint-v1/splice-api-token-burnmintv1]

step 結果が返る
  say 結果は、作ったholdingのIDの一覧を、引数に指定した出力と同じ順で持ちます。
  F -> A: 作ったholdingのID
  source Splice.Api.Token.BurnMintV1 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-burn-mint-v1/splice-api-token-burnmintv1]
```

## holdingの変化をイベントで報告する

`TransferEventsV2`のmoduleは、Token Standardのtransferのイベントを記録するinterfaceです。
interfaceの`EventLog`は、Token Standard V2のイベントを報告するのに使えるtemplateのためのinterfaceで、viewは`EventLogView`です。
`EventLog`のnonconsumingのchoiceは、instrumentのadminがトークンのtransferを報告するのに使います。
トークンのtransferのイベントとして扱うのは、instrumentのadminからのイベントだけにします。

nonconsumingは、choiceを実行してもコントラクトをarchiveしないことを表します。
`EventLog`は、choiceの`Archive`と、methodの`eventLog_holdingsChangeImpl`を持ちます。
`EventLogView`は、`admin`と`meta`を持ちます。
`EventLog`のコントラクトは、instrumentのadminかアプリの提供者だけが使う前提なので、publicのfetchを持ちません。

choiceの`EventLog_HoldingsChange`は、1つのaccountのholdingの変化をobserverに知らせます。
controllerは`admin`で、`EventLog_HoldingsChangeResult`を返します。
資産のadminは、発行するイベント全体が、全ての通常のaccountのholdingの全ての変化と、全ての通常のaccountへの出入りのtransferを説明することを、必ず保証します。

1回のchoiceが報告するのは、`account`に指定した1つのaccountの変化です。
holdingの変化には、1つのトランザクションの中で作ってarchiveしたholdingを含みます。

`EventLog_HoldingsChange`は、7つの欄を受け取ります。

| 欄 | 内容 |
|---|---|
| `admin` | holdingの変化を報告するinstrumentのadmin |
| `account` | 変化があったaccount |
| `inputHoldingCids` | 消費したaccountのholding |
| `transferLegSides` | transferの片側の一覧 |
| `outputHoldingCids` | accountの新しく作ったholding |
| `observers` | 変化を知らされるparty。少なくとも`account`のpartyを含む |
| `extraArgs` | イベントのmetadataと追加の文脈 |

`inputHoldingCids`は、同じトランザクションでarchiveされ、この変化で指定した`account`が持つholdingです。
同じトランザクションの中で作ってarchiveしたholdingを含めてもかまいません。
その場合、そのholdingのコントラクトIDは、入力と出力の両方の一覧に現れます。

`transferLegSides`の一覧が持つ正味の残高の変化の合計は、`account`のholdingの変化に一致します。
1件のtransferの片側だけが、残高の変化に一致するのではありません。
transferの両側を報告して、そのIDを一致させます。
違うtransfer legのIDは、一意にします。

正味の残高の変化が0のtransferの決済は、入力と出力のholdingが空のイベントになってもかまいません。
holdingの合併と分割は、トークンの自分へのtransferと関係しないことがあるので、空のtransfer legの一覧で報告してもかまいません。

`TransferEventsV2`の`TransferLegSide`は、2つのpartyの間のholdingのtransferの片側で、影響を受けるaccountのtransferのイベントを報告するのに使います。
`transferLegId`は、送り手と受け手の側を結び付けるための識別子です。

`observers`は、`account`のpartyを必ず含み、そのほかのpartyを加えて指定できます。
`extraArgs`は、イベントのmetadataと追加の文脈を蓄え、holdingの変化全体の理由は`splice.lfdecentralizedtrust.org/reason`で説明します。
コントラクトIDは`Text`として蓄えられず、`Metadata`だけではコントラクトIDへのリンクを残せません。
このため、`ChoiceContext`を与えて、追加のリンクを蓄えられるようにします。

`EventLog_HoldingsChangeResult`は欄を持たず、interfaceをアップグレードできるようになる将来の拡張のためにあります。

`TransferEventsV2`のmoduleの参照の頁は、最新のリリースを0.10.3と示します。
packageの一覧は、頁「Token Standardの版と並び」が追っています。

https://cardene.dev/diagrams/canton-token-api-packages

下の図は、adminがholdingの変化を1件報告し、observerが知らされるまでを、報告に入れる物と一緒に追います。

```dragon
architecture holdingの変化の報告

group Rep as 報告する側 [color: slate, icon: server]
  box Adm as instrumentのadmin [note: 報告する, color: blue, icon: user]
  box Log as EventLog [note: choice, color: slate, icon: layers]
end
group Body as 1件の報告に入れる物 [color: slate, icon: card]
  box In as 消費したholding [note: archiveする, color: rose, icon: card]
  box Out as 新しく作ったholding [note: 新しいholding, color: rose, icon: card]
  box Leg as transferの片側の一覧 [note: 残高の変化と一致, color: rose, icon: card]
end
group Know as 知らされる側 [color: slate, icon: user]
  box Obs as accountのparty [note: 必ず含める, color: blue, icon: user]
  box Ext as 加えたparty [note: 追加で指定, color: blue, icon: user]
end

step adminが報告する
  say instrumentのadminは、EventLogのchoiceで、1つのaccountのholdingの変化を1件報告します。
  Adm -> Log: 報告する
  source Splice.Api.Token.TransferEventsV2 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-transfer-events-v2/splice-api-token-transfereventsv2]

step 報告に入れる物
  say 報告は、消費したholdingと、新しく作ったholdingと、transferの片側の一覧を持ちます。
  act In: 消費したholding
  act Out: 新しく作ったholding
  act Leg: 合計が残高の変化と一致する
  source Splice.Api.Token.TransferEventsV2 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-transfer-events-v2/splice-api-token-transfereventsv2]

step observerに知らせる
  say choiceは、holdingの変化を、accountのpartyと加えて指定したpartyに知らせます。
  Log -> Obs: 必ず知らせる
  Log -> Ext: 加えた分も知らせる
  source Splice.Api.Token.TransferEventsV2 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-transfer-events-v2/splice-api-token-transfereventsv2]
```

## 次に読む頁

次の頁「Amuletが送金を実装する形」は、AmuletがToken Standardの送金とallocationをどう実装し、2段の送金とmetadataとchoice contextをどう扱うかを追います。

https://cardene.dev/diagrams/canton-amulet-token-standard

## 出典

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-burn-mint-v1/splice-api-token-burnmintv1

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-transfer-events-v2/splice-api-token-transfereventsv2
