# external partyと事前承認で送る

> external partyのホストの提案と、事前承認と、準備から実行まで24時間の遅れを許す設定を、表と2つの図で追います。

- URL: https://cardene.dev/diagrams/canton-external-party-cc
- 公開日: 2026-11-22
- 更新日: 2026-11-22
- トピック: Blockchain
- タグ: Canton
- 親の図解: [Amuletの送金](https://cardene.dev/diagrams/canton-amulet-transfers.md): Canton Coinを表すAmuletの一括の送金を、入力と出力とcontextの中身から、章の中の図解で追います。

external partyは、トランザクションを準備してから署名するまでに、長い遅れを置けます。
この頁では、external partyのホストの提案から、事前承認の`TransferPreapproval`、準備から実行まで24時間の遅れを許す設定までを、`Splice.AmuletRules`と`Splice.ExternalPartyAmuletRules`と`Splice.ExternalPartyConfigState`のモジュールから追います。
そこで、まず設定の提案と事前承認のchoiceを見て、次にexternal partyの送金のcontextと、遅れを許す設定のコントラクトを見ます。

外部署名のpartyは、頁「外部署名のparty」で見ました。

https://cardene.dev/diagrams/canton-external-party

準備と署名と実行の手順は、頁「外部の鍵でpartyを動かす」で見ました。

https://cardene.dev/diagrams/canton-external-signing

事前承認と、validatorのAPIが作る設定の提案は、頁「受け手が前もって受け取りを許す」で見ました。

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

`Transfer`と`TransferResult`と`TransferContext`と`PaymentTransferContext`と`TransferInput`と、Optionalは、頁「Canton Coinを送る」で見ました。

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

Token Standardは、頁「Canton Coinの役と料金を知る」で見ました。

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

## external partyのホストを提案する

前の頁は、validatorのAPIが作る設定の提案を、署名の流れで見ました。
この節は、その提案を作るchoiceと、提案のtemplateとchoiceを追います。

`AmuletRules_CreateExternalPartySetupProposal`は、external partyをホストすることを提案するchoiceです。
この流れで提供者になるvalidatorの運用者のpartyは、external partyに代わって`TransferPreapproval`を作る料金を、このchoiceを行う時に前払いします。
controllerは`validator`です。
受け取る欄は、次の表の6つです。

| 欄 | 型 |
|---|---|
| `context` | `PaymentTransferContext` |
| `inputs` | `[TransferInput]` |
| `user` | `Party` |
| `validator` | `Party` |
| `preapprovalExpiresAt` | `Time` |
| `expectedDso` | `Optional Party` |

返す`AmuletRules_CreateExternalPartySetupProposalResult`は、次の表の6つの欄を持ちます。

| 欄 | 型 |
|---|---|
| `proposalCid` | `ContractId ExternalPartySetupProposal` |
| `user` | `Party` |
| `validator` | `Party` |
| `transferResult` | `TransferResult` |
| `amuletPaid` | `Decimal` |
| `meta` | `Optional Metadata` |

`ExternalPartySetupProposal`のtemplateは、signatoryが`validator`と`dso`で、次の表の5つの欄を持ちます。

| 欄 | 型 |
|---|---|
| `validator` | `Party` |
| `user` | `Party` |
| `dso` | `Party` |
| `createdAt` | `Time` |
| `preapprovalExpiresAt` | `Time` |

`ExternalPartySetupProposal`は、次の表の4つのchoiceを持ちます。
`ExternalPartySetupProposal_Accept`は、前の頁でexternal partyが署名したchoiceで、controllerは`user`です。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `ExternalPartySetupProposal_Accept` | `user` | なし | `ExternalPartySetupProposal_AcceptResult`。欄`validatorRightCid`と`transferPreapprovalCid`で、`ValidatorRight`と`TransferPreapproval`を返す |
| `ExternalPartySetupProposal_Reject` | `user` | `Text`の`reason` | `ExternalPartySetupProposal_RejectResult`。欄は`dummyArg`だけ |
| `ExternalPartySetupProposal_Withdraw` | `validator` | `Text`の`reason` | `ExternalPartySetupProposal_WithdrawResult`。欄は`dummyArg`だけ |
| `Archive` | `validator`と`dso`の2者 | なし | `()` |

次の図Aでは、設定の提案を作るchoiceと、表の`Archive`を除く3つのchoiceを、操作ごとの枝として足して追います。
この図では、枝は、操作と、その操作を行うpartyと、操作が返す物の入れ子だけを示し、操作が起きる順は示しません。

```dragon
mind 設定の提案を作る操作と3つの操作

step 設定の提案
  say 設定の提案のコントラクトを中心に、提案を作る操作と、承諾する、断る、取り下げるの3つの操作を、枝として足します。
  idea root as "設定の提案" [color: slate]
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 提案を作る
  say validatorの運用者のpartyは、external partyに代わって事前承認を作る料金を前払いして、提案を作ります。
  idea cr as "作る" of root [color: blue]
  idea cr1 as "運用者のpartyが行う" of cr
  idea cr2 as "料金を前払いする" of cr
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 提案を承諾する
  say external partyは、提案を承諾します。承諾のchoiceは、報酬のmintに要る権利のコントラクトを返します。
  idea ac as "承諾する" of root [color: rose]
  idea ac1 as "external partyが行う" of ac
  idea ac2 as "権利のコントラクトを返す" of ac
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 承諾が返す事前承認
  say 承諾のchoiceは、事前承認のコントラクトも返します。
  idea ac3 as "事前承認のコントラクトを返す" of ac
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 提案を断る
  say external partyは、理由を渡して、提案を断ることもできます。
  idea rj as "断る" of root [color: rose]
  idea rj1 as "external partyが行う" of rj
  idea rj2 as "理由を渡す" of rj
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 提案を取り下げる
  say validatorの運用者のpartyは、理由を渡して、提案を取り下げます。
  idea wd as "取り下げる" of root [color: blue]
  idea wd1 as "運用者のpartyが行う" of wd
  idea wd2 as "理由を渡す" of wd
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]
```

## AmuletRulesから事前承認を作る

`AmuletRules_CreateTransferPreapproval`は、入ってくる`Amulet`の送金を前もって承認するchoiceです。
controllerは、`provider`と`receiver`の2者です。
受け取る欄は、次の表の6つです。

| 欄 | 型 |
|---|---|
| `context` | `PaymentTransferContext` |
| `inputs` | `[TransferInput]` |
| `receiver` | `Party` |
| `provider` | `Party` |
| `expiresAt` | `Time` |
| `expectedDso` | `Optional Party` |

返す`AmuletRules_CreateTransferPreapprovalResult`は、次の表の4つの欄を持ちます。

| 欄 | 型 |
|---|---|
| `transferPreapprovalCid` | `ContractId TransferPreapproval` |
| `transferResult` | `TransferResult` |
| `amuletPaid` | `Decimal` |
| `meta` | `Optional Metadata` |

## TransferPreapprovalのtemplate

`TransferPreapproval`のtemplateは、受け手がだれからでも`Amulet`を受け取ることを、前もって承認したものです。
事前承認は、期限が切れるまで、Super Validatorが索引に載せ、見つけやすいようにScanから配ります。
この見つけるための仕組みを提供する費用は、`Amulet`をburnして取ります。
受け手は、事前承認を自分で買って更新するか、管理する事前承認を通った`Amulet`の送金のアプリの報酬と引き換えに、アプリの提供者に任せるかを選べます。

signatoryは`receiver`と`provider`と`dso`で、欄は次の表の6つです。

| 欄 | 型 | 中身 |
|---|---|---|
| `dso` | `Party` | |
| `receiver` | `Party` | 受け手 |
| `provider` | `Party` | 受け手の事前承認を管理するアプリの提供者。受け手が自分で管理する事前承認では、受け手と同じ |
| `validFrom` | `Time` | 事前承認の料金を払った期間の始まり。更新をまたいで保たれる |
| `lastRenewedAt` | `Time` | 最後に更新した時。作った時は`validFrom`と同じにし、更新のたびに変わる |
| `expiresAt` | `Time` | 提供者が選ぶ、コントラクトの寿命の終わり。コントラクトを更新すると延ばせる |

## TransferPreapprovalのchoice

`TransferPreapproval`は、次の表の6つのchoiceを持ちます。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `TransferPreapproval_Renew` | `provider` | `PaymentTransferContext`の`context`、`[TransferInput]`の`inputs`、`Time`の`newExpiresAt` | `TransferPreapproval_RenewResult`。欄`transferPreapprovalCid`と`transferResult`と`receiver`と`provider`と`amuletPaid`と`meta` |
| `TransferPreapproval_SendV2` | `sender` | `ExternalPartyTransferContext`の`context`、`[TransferInput]`の`inputs`、`Decimal`の`amount`、`Party`の`sender`、省略可の`Text`の`description` | `TransferPreapproval_SendV2Result`。欄`result`は`TransferResult`、欄`meta`は`Metadata` |
| `TransferPreapproval_Cancel` | 引数のparty`p` | `Party`の`p` | `TransferPreapproval_CancelResult` |
| `TransferPreapproval_Expire` | `dso` | なし | 欄の無い`TransferPreapproval_ExpireResult` |
| `TransferPreapproval_Fetch` | 引数のparty`p` | `Party`の`p` | `TransferPreapproval`そのもの |
| `Archive` | `receiver`と`provider`と`dso`の3者 | なし | `()` |

関数`computeTransferPreapprovalFee`は、`RelTime`と`AmuletConfig USD`と`TransferContext`と`Party`を受け取り、`(Decimal, Decimal)`を返します。

## external partyの送金のcontext

`ExternalPartyTransferContext`は、キーでなくコントラクトのIDで参照できるように、送金へ渡すコントラクトをまとめた型です。
次の表の2つの欄を持ちます。

| 欄 | 型 |
|---|---|
| `externalPartyConfigState` | `ContractId ExternalPartyConfigState` |
| `featuredAppRight` | `Optional (ContractId FeaturedAppRight)` |

`featuredAppRight`は、`provider`がfeatured app providerである任意の証明です。
external partyの送金のcontextを扱う関数は、次の表の4つです。

| 関数 | 受け取る物 | 返す物 |
|---|---|---|
| `executeExternalPartyTransfer` | `Party`、`ExternalPartyTransferContext`、`Transfer` | `Update TransferResult` |
| `summarizeAndValidateExternalPartyContext` | `ExternalPartyTransferContext`、`Party`、`Transfer` | `Update TransferContextSummaryV2` |
| `externalPartyTransferFromChoiceContext` | `Party`、`ChoiceContext` | `Update ExternalPartyTransferContext` |
| `unfeaturedPaymentContextFromChoiceContext` | `Party`、`ChoiceContext` | `Update ExternalPartyTransferContext` |

`executeExternalPartyTransfer`は、external partyの送金を、準備したトランザクションが24時間有効なままになるように実行します。
`unfeaturedPaymentContextFromChoiceContext`は、`externalPartyTransferFromChoiceContext`と同じ型を持ち、contextに`featuredAppRight`があっても無視したい時に使います。

## 24時間の遅れを許す設定

`ExternalPartyConfigState`のtemplateは、送金と`allocation`とtrafficの購入と`tap`に要る設定を持ちます。
signatoryは`dso`です。
`OpenMiningRound`にもある情報の一部を出しますが、ずっと長く有効なので、トランザクションの準備から実行まで24時間の遅れを許します。
`tap`は、頁「4つの環境の違いと入り方」で見た語です。

https://cardene.dev/diagrams/canton-environments

常に2つの`ExternalPartyConfigState`のコントラクトが、互いにおよそ`externalPartyConfigStateTickDuration`離れて作られ、それぞれ`2 * externalPartyConfigStateTickDuration`の間有効です。
`externalPartyConfigStateTickDuration`は、`AmuletConfig`の欄で、頁「Canton Coinの設定を変える」で見ました。

https://cardene.dev/diagrams/canton-amulet-config

欄は、次の表の5つです。

| 欄 | 型 | 中身 |
|---|---|---|
| `dso` | `Party` | |
| `holdingFeesOpenRoundNumber` | `Round` | 新しく作るコントラクトの保有の料金に使うroundの番号 |
| `amuletPrice` | `Decimal` | 作った時の`Amulet`の価格 |
| `transferConfig` | `TransferConfigV2 USD` | 作った時の送金の設定 |
| `targetArchiveAfter` | `Time` | コントラクトがアーカイブされる時刻の下限で、厳しい上限としては強制しない |

`Archive`のchoiceは、controllerが`dso`で、`()`を返します。

`AmuletRules`は、このコントラクトを扱うchoiceを2つ持ちます。
どちらもcontrollerは`dso`です。

| choice | 受け取る物 | 返す物 |
|---|---|---|
| `AmuletRules_BootstrapExternalPartyConfigState` | `OpenMiningRoundTriple`の`openMiningRoundTriple`、`Party`の`expectedDso` | 欄の無い`AmuletRules_BootstrapExternalPartyConfigStateResult` |
| `AmuletRules_UpdateExternalPartyConfigStates` | `ContractId ExternalPartyConfigState`の`externalPartyConfigStateCid0`と`externalPartyConfigStateCid1`、`openMiningRoundTriple` | 欄`newExternalPartyConfigStateCid` |

関数`bootstrapExternalPartyConfigState`は、`AmuletRules`と`OpenMiningRoundTriple`を受け取り、`Update ()`を返します。

次の図Bでは、external partyの送金を準備して署名し、実行するまでを追います。
この図では、準備と署名と実行の順を、前に見た外部署名の手順で描き、設定を指す段を準備の段の前に置きます。
設定を指す段は、線を置かず、設定のコントラクトを言う段です。
2つの設定のコントラクトが重なる様子は、図に描きません。

```dragon
sequence 準備から実行までの24時間

box C as 設定のコントラクト [note: 長く有効, color: slate, icon: doc]
box N as Participant Node [note: 準備と実行, color: blue, icon: server]
box E as external party [note: 自分の鍵で署名する, color: rose, icon: user]

step 設定を指す
  say external partyの送金のcontextは、設定のコントラクトを、コントラクトのIDで指します。
  act C: contextから指される
  source CantonのSplice.ExternalPartyConfigState [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-externalpartyconfigstate]
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 送金を準備して返す
  say Participant Nodeは、external partyの送金を準備して、external partyに返します。
  N -> E: 準備した送金
  source CantonのExternal Signing [url: https://docs.canton.network/appdev/deep-dives/external-signing]

step 署名までの遅れ
  say 準備から実行までに24時間の遅れを置けるのは、設定のコントラクトが長く有効だからです。
  act C: 長く有効
  source CantonのSplice.ExternalPartyConfigState [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-externalpartyconfigstate]

step 署名を返す
  say external partyは、準備された送金に署名して、Participant Nodeに返します。
  E -> N: 署名
  source CantonのExternal Signing [url: https://docs.canton.network/appdev/deep-dives/external-signing]

step 送金を実行する
  say external partyの送金の実行は、準備したトランザクションが24時間有効なままになるように行われます。
  act N: 送金を実行する
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]
```

## ExternalPartyAmuletRules

`ExternalPartyAmuletRules`のtemplateは、external partyの署名を要するトランザクションで使える規則のコントラクトです。
signatoryは`dso`で、欄も`dso`だけで、`Archive`のcontrollerは`dso`です。
準備から署名までの長い遅れを支えるため、アーカイブして作り直すことを、できるだけ少なくする意図で作られています。

Token Standardの`AllocationFactory`と`TransferFactory`のinterfaceを実装し、次の表の2つの関数を持ちます。

| 関数 | 受け取る物 | 返す物 |
|---|---|---|
| `amulet_transferFactory_transferImpl` | `ExternalPartyAmuletRules`、`ContractId TransferFactory`、`TransferFactory_Transfer` | `Update TransferInstructionResult` |
| `amulet_allocationFactory_allocateImpl` | `ExternalPartyAmuletRules`、`ContractId AllocationFactory`、`AllocationFactory_Allocate` | `Update AllocationInstructionResult` |

`ExternalPartyAmuletRules`は、`Archive`のほかに、次の表の2つのchoiceを持ちます。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `ExternalPartyAmuletRules_CreateTransferCommand` | `sender` | `Party`の`sender`と`receiver`と`delegate`、`Decimal`の`amount`、`Time`の`expiresAt`、`Int`の`nonce`、省略可の`Text`の`description`、`Optional Party`の`expectedDso` | `ExternalPartyAmuletRules_CreateTransferCommandResult`。欄`transferCommandCid`は`ContractId TransferCommand` |
| `ExternalPartyAmuletRules_ExpireAmuletAllocations` | `dso` | `Party`の`expectedDso`、`[ExternalPartyAmuletRules_ExpireAmuletAllocationInput]`の`inputs`、`[Party]`の`observers` | `ExternalPartyAmuletRules_ExpireAmuletAllocationsResult`。欄`results`は`[AmuletAllocation_DsoExpireResult]` |

`ExternalPartyAmuletRules_CreateTransferCommand`が作る`TransferCommand`は、非推奨の旧方式で、後継の型はありません。
代わりの処理には、Token Standardの送金のAPIを使います。
どの型が何に置き換わったかは、第11部の頁「SpliceのDamlの古い型と移り先」が追っています。

https://cardene.dev/diagrams/canton-splice-deprecated-daml

`ExternalPartyAmuletRules_ExpireAmuletAllocationInput`は、`ContractId AmuletAllocation`の`allocationCid`と、`Bool`の`expireLock`を持ちます。

関数`requireExpectedAdminMatch`は、2つの`Party`を受け取り、期待した管理者と一致することを求め、`Update ()`を返します。

## AmuletRulesのExpireのchoice

`AmuletRules_Amulet_ExpireTransferInstructions`は、controllerが`dso`で、`Party`の`expectedDso`、`[AmuletRules_ExpireTransferInstructionInput]`の`inputs`、`[Party]`の`observers`を受け取ります。
欄`results`が`[TransferInstructionResult]`の結果を返します。
`AmuletRules_ExpireTransferInstructionInput`は、`ContractId TransferInstruction`の`transferInstructionCid`と、`Bool`の`expireLock`を持ちます。

## 次に読む頁

次の章「Splice WalletとCNS」の1頁目の頁「組み込みのwalletで送金する」は、validatorに組み込まれたSplice Walletが、Canton Coinをどう送り、何を自動で行い、どのAPIを出すかを追います。

https://cardene.dev/diagrams/canton-wallet

## 出典

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-externalpartyamuletrules

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-externalpartyconfigstate

https://docs.canton.network/appdev/deep-dives/external-signing
