# 送金の料金と失敗の理由を知る

> 送金の要約TransferSummaryの欄と、料金と時と共に減る量の型と、送金が失敗する理由を、表と3つの図で追います。

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

前の頁「Canton Coinを送る」では、一括の送金が返す`TransferResult`の欄`summary`を、入力と出力の量と、払った料金の要約として見ました。
この頁では、その`TransferSummary`が持つ欄、料金と時と共に減る量の型と計算の関数、送金が失敗する理由を追います。
そこで、まず要約の欄を表で追い、次に料金の型と関数、最後に失敗の理由を、表と図で追います。

`Transfer`と`TransferResult`と`TransferOutput`と、Optionalとvariantは、前の頁で見ました。

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

どの料金が実際に掛かるかと、mining roundとactivity recordは、頁「Canton Coinの役と料金を知る」で見ました。

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

その頁は、CIP-0078が送金の料金とロックの料金を除いたと書きます。
この頁の欄と型は資料が載せる型で、除いた後の値は追いません。

CIPは、頁「CIPが承認され効力を持つまで」で見ました。

https://cardene.dev/diagrams/canton-cip-process

reward couponは、報酬の引換券です。

## 送金の要約が記す入力の量

`TransferSummary`は、入力と出力の量と、払った料金の要約です。
トランザクションの要約を表示する時に、送金を始めた`Transfer`の指定と合わせて使います。
台帳の外で計算するのが難しい主要な数を、手早く得るためにあります。

入力の量の欄は、次の表の7つです。
それぞれ、送金へ入れたreward couponと`Amulet`とactivity recordの発行の合計を示します。

| 欄 | 型 | 合計する物 |
|---|---|---|
| `inputAppRewardAmount` | `Decimal` | app reward couponの発行 |
| `inputValidatorRewardAmount` | `Decimal` | validator reward couponの発行 |
| `inputSvRewardAmount` | `Decimal` | SV reward couponの発行 |
| `inputAmuletAmount` | `Decimal` | `Amulet`の入力 |
| `inputValidatorFaucetAmount` | `Optional Decimal` | validator faucet couponの発行 |
| `inputUnclaimedActivityRecordAmount` | `Optional Decimal` | unclaimed activity recordの発行 |
| `inputDevelopmentFundAmount` | `Optional Decimal` | development fund couponの発行 |

`inputAmuletAmount`は、保有の料金を引く前の、送金へ入れた`Amulet`の合計です。
`inputValidatorFaucetAmount`は、CIP-3で足された欄です。

## 料金と残高の欄

料金と残高の欄は、次の表の6つです。

| 欄 | 型 | 中身 |
|---|---|---|
| `balanceChanges` | `Map Party BalanceChange` | partyごとの残高の変化 |
| `holdingFees` | `Decimal` | 送り手が入力の`Amulet`に払った保有の料金 |
| `outputFees` | `[Decimal]` | 出力ごとの料金を、指定した順に並べた一覧 |
| `senderChangeFee` | `Decimal` | 送り手へお釣りを返す料金 |
| `senderChangeAmount` | `Decimal` | 全ての出力と料金を払った後に送り手へ返す最後の量。0なら送り手の`Amulet`は作られない |
| `amuletPrice` | `Decimal` | 送金を実行したroundの`Amulet`の価格 |

`senderChangeFee`は、全ての出力を払った後の残りと、`Amulet`を1つ作る料金の、小さい方になります。
残りが作る料金より小さい時は、残りの全てがお釣りを返す料金に消えます。
この時は、送り手の`Amulet`は作られず、`senderChangeAmount`は0になりますが、送金は成功します。
お釣りを返さない送金では、全ての出力を払った後の残りは必ず0になり、`senderChangeFee`も0になります。

## 入力の合計と残高の変化

`TransferInputsSummary`は、次の表の10の欄を持ちます。

| 欄 | 型 |
|---|---|
| `totalAmuletAmount` | `Decimal` |
| `totalAppRewardAmount` | `Decimal` |
| `totalValidatorRewardAmount` | `Decimal` |
| `totalValidatorFaucetAmount` | `Decimal` |
| `totalSvRewardAmount` | `Decimal` |
| `totalHoldingFees` | `Decimal` |
| `amountArchivedAsOfRoundZero` | `Decimal` |
| `changeToHoldingFeesRate` | `Decimal` |
| `totalUnclaimedActivityRecordAmount` | `Optional Decimal` |
| `totalDevelopmentFundAmount` | `Optional Decimal` |

`totalValidatorFaucetAmount`は、台帳に保存されない型の欄なので、`Optional`にしません。
`inputUnclaimedActivityRecordAmount`と`inputDevelopmentFundAmount`と、この表の`totalUnclaimedActivityRecordAmount`と`totalDevelopmentFundAmount`は、`Optional`にしてあります。
これは、`TransferSummary`と`TransferInputsSummary`がシリアライズできる型で、欄の追加を、パッケージのアップロードの時に、アップグレードの検査が確かめるためです。

`BalanceChange`は、次の表の2つの欄を持ちます。
`Additive`のインスタンスを持ち、足し合わせられます。

| 欄 | 型 | 中身 |
|---|---|---|
| `changeToInitialAmountAsOfRoundZero` | `Decimal` | round 0に正規化した、総残高の変化 |
| `changeToHoldingFeesRate` | `Decimal` | 保有の料金の総額の変化 |

round 0への正規化では、round 3で作られた`Amulet`を、初めの量がより多いround 0で作られた`Amulet`として扱います。

## 出力の要約と料金の計算

`PreprocessedTransferOutput`は、次の表の4つの欄を持ちます。
`TransferOutputsSummary`は、その一覧の`[PreprocessedTransferOutput]`の別名です。

| 欄 | 型 | 中身 |
|---|---|---|
| `owner` | `Party` | 出力の所有者 |
| `outputFee` | `Decimal` | この出力を作る料金 |
| `amount` | `Decimal` | 料金を引いた後に、出力が持つ`Amulet`の量 |
| `lock` | `Optional TimeLock` | `Amulet`をロックするか |

`AmuletRules_ComputeFees`は、与えたcontextに対する、送金の出力の料金を計算するchoiceです。
controllerは`sender`で、次の表の4つの欄を受け取ります。
返す`AmuletRules_ComputeFeesResult`は、`[Decimal]`の欄`fees`を持ちます。

| 欄 | 型 |
|---|---|
| `context` | `TransferContext` |
| `sender` | `Party` |
| `outputs` | `[TransferOutput]` |
| `expectedDso` | `Optional Party` |

## 料金と減る量の型

`Splice.Fees`のモジュールは、いろいろな種類の料金を計算するための関数と型をまとめます。
次の表の5つの型が、料金と時と共に減る量を表します。

| 型 | 欄 | 中身 |
|---|---|---|
| `ExpiringAmount` | `initialAmount`は`Decimal`、`createdAt`は`Round`、`ratePerRound`は`RatePerRound` | 時と共に減る量 |
| `FixedFee` | `fee`は`Decimal` | 行う操作に関わらず一定の料金 |
| `RatePerDay` | `rate`は`Decimal` | 1日あたりの率 |
| `RatePerRound` | `rate`は`Decimal` | 1roundあたりの率 |
| `SteppedRate` | `initialRate`は`Decimal`、`steps`は`Decimal`の組の一覧 | 区分ごとに線形な関数で決まる率 |

`SteppedRate 0.01 [(100.0, 0.001), (1000.0, 0.0001), (1000000, 0.00001)]`は、最初の100に1%、100から1000に0.1%、1000から1000000に0.01%、それより上に0.001%を課します。
`FixedFee`と`RatePerRound`と`SteppedRate`は、`Patchable`のインスタンスを持ち、設定の一部を差分で書き換えられます。

この5つの型を、欄の型に持つ所は、次の表の7つです。

| 欄を持つ型 | 欄 | 型 |
|---|---|---|
| `Amulet` | `amount` | `ExpiringAmount` |
| `TransferConfig` | `createFee` | `FixedFee` |
| `TransferConfig` | `lockHolderFee` | `FixedFee` |
| `TransferConfig` | `holdingFee` | `RatePerRound` |
| `TransferConfigV2` | `holdingFee` | `RatePerRound` |
| `ExpiringAmount` | `ratePerRound` | `RatePerRound` |
| `TransferConfig` | `transferFee` | `SteppedRate` |

次の図Aでは、`Amulet`から、欄の型を順にたどって追います。
この図では、枝は欄の型の入れ子だけを示します。
欄の名前は、上の表で見ます。

```dragon
mind Amuletが持つ量の型

step Amuletが持つ量
  say Amuletが持つ量の型は、時と共に減る量の型です。
  idea root as "Amulet" [color: slate]
  idea e as "ExpiringAmount" of root [color: blue]
  source CantonのSplice.Fees [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-fees]

step 時と共に減る量の率
  say 時と共に減る量の型は、1roundあたりの率の型を持ちます。
  idea r as "RatePerRound" of e [color: rose]
  source CantonのSplice.Fees [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-fees]
```

次の図Bでは、設定の`TransferConfig`から、欄の型を順にたどって追います。
この図では、枝は欄の型の入れ子だけを示します。
`TransferConfigV2`の`holdingFee`は、表で見ます。

```dragon
mind 設定が持つ料金の型

step 一定の料金
  say 設定のTransferConfigは、作る料金とロックの料金に、一定の料金の型を持ちます。
  idea root as "TransferConfig" [color: slate]
  idea f as "FixedFee" of root [color: blue]
  source CantonのSplice.Fees [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-fees]

step 保有の料金の率
  say 設定のTransferConfigは、保有の料金に、1roundあたりの率の型を持ちます。
  idea r as "RatePerRound" of root [color: blue]
  source CantonのSplice.Fees [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-fees]

step 送金の料金の率
  say 設定のTransferConfigは、送金の料金に、区分ごとの率の型を持ちます。
  idea s as "SteppedRate" of root [color: blue]
  source CantonのSplice.Fees [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-fees]
```

## 率と減る量を計算する関数

率と減る量を計算する関数は、次の表の9つです。

| 関数 | 受け取る物 | 返す物 | 中身 |
|---|---|---|---|
| `chargeRatePerRound` | `RatePerRound`、経過したroundの数の`RelRound` | `Decimal` | 課す額 |
| `chargeSteppedRate` | `SteppedRate`、`Decimal` | `Decimal` | 課す額。補助の`goChargeSteppedRate`が段を順にたどって計算する |
| `chargeRatePerDay` | `RatePerDay`、時間の長さの`RelTime` | `Decimal` | 課す額 |
| `ratePerRoundToRatePerDay` | `RatePerRound`、1roundの長さの`RelTime` | `RatePerDay` | 1roundあたりの率を、1日あたりの率に直した値 |
| `scaleRatePerRound` | `Decimal`、`RatePerRound` | `RatePerRound` | roundの率を倍した値 |
| `scaleFixedFee` | `Decimal`、`FixedFee` | `FixedFee` | `FixedFee`を倍した値 |
| `scaleSteppedRate` | `Decimal`、`SteppedRate` | `SteppedRate` | 固定と変動の率を倍した値 |
| `expiringAmount` | `RatePerRound`、初めの量の`Decimal`、作ったroundの`Round` | `ExpiringAmount` | `ExpiringAmount`を作る |
| `getValueAsOfRound0` | `ExpiringAmount` | `Decimal` | round 0の時点に換算した値 |

倍率の関数は、任意の倍率`s`について、次の等式が成り立つように率を倍します。
`r`は率、`dt`は`chargeRatePerRound`が受け取る経過したroundの数、`q`は`chargeSteppedRate`が受け取る量です。

`s * chargeRatePerRound r dt = chargeRatePerRound (s scaleRatePerRound r) dt`

`s * chargeSteppedRate r (q/s) = chargeSteppedRate (s scaleSteppedRate r) q`

値が正しい形かを`Bool`で返す関数は、次の表の4つです。

| 関数 | 受け取る物 |
|---|---|
| `positiveRatePerRound` | `RatePerRound` |
| `positiveFixedFee` | `FixedFee` |
| `validSteppedRate` | `SteppedRate` |
| `validExpiringAmount` | `ExpiringAmount` |

時間の長さを数に直す関数は、次の表の5つです。

| 関数 | 受け取る物 | 返す物 |
|---|---|---|
| `relTimeToMicros` | `RelTime` | `Decimal` |
| `microsPerDay` | なし | `Decimal` |
| `relTimeToDays` | `RelTime` | `Decimal` |
| `daysToRelTime` | `Decimal` | `RelTime` |
| `relTimeToSeconds` | `RelTime` | `Decimal` |

## 設定と要約を扱う関数

送金の設定と要約を扱う関数は、次の表の6つです。

| 関数 | 受け取る物 | 返す物 |
|---|---|---|
| `transferConfigAmuletFromOpenRound` | `OpenMiningRound` | `TransferConfig Amulet` |
| `scaleFees` | `Decimal`、`TransferConfig USD` | `TransferConfig Amulet` |
| `scaleFees2` | `Decimal`、`TransferConfigV2 USD` | `TransferConfigV2 Amulet` |
| `splitAndBurn` | `Party`、`Decimal`、`[TransferInput]`、`TransferContext`、`Party`、`Text` | `TransferResult`と`Metadata`の組 |
| `totalBurnFromSummary` | `TransferSummary` | `Decimal` |
| `legacyAmuletCreateSummary` | 2つの`Party`、`ContractId OpenMiningRound`、`ContractId Amulet` | `AmuletCreateSummary (ContractId Amulet)` |

`transferConfigAmuletFromOpenRound`は、そのroundの`TransferConfig Amulet`を返します。
`scaleFees`は、取る料金が同じ倍率で変わるように、設定を倍率で直します。
`scaleFees2`は、同じことを`TransferConfigV2`に行います。
`totalBurnFromSummary`は、送金の中でburnした総量を計算します。

## 送金が失敗する理由

送金の失敗に関わる名前は、`InvalidTransferReason`の5つの形と、失敗の状態を返す5つの関数です。
`InvalidTransferReason`はvariantで、次の表の5つの形を持ちます。

| 形 | 欄 |
|---|---|
| `ITR_InsufficientFunds` | `missingAmount`は`Decimal` |
| `ITR_UnknownSynchronizer` | `synchronizerId`は`Text` |
| `ITR_InsufficientTopupAmount` | `requestedTopupAmount`と`minTopupAmount`は、どちらも`Int` |
| `ITR_Other` | `description`は`Text` |
| `ExtInvalidTransferReason` | `dummyUnitField`は`()` |

`ExtInvalidTransferReason`は、前の頁で見た拡張の形です。

失敗の状態の`FailureStatus`を返す関数は、次の表の5つです。

| 関数 | 受け取る物 | 返す物 |
|---|---|---|
| `mkUnknownSynchronizerFailure` | `Text` | `FailureStatus` |
| `mkInsufficientTopupAmountFailure` | 2つの`Int` | `FailureStatus` |
| `mkMaximumInputsExceededFailure` | なし | `FailureStatus` |
| `mkMaximumOutputsExceededFailure` | なし | `FailureStatus` |
| `mkInsufficientFundsFailure` | `Decimal` | `FailureStatus` |

関数`mkFailureStatus`は、`Text`と`FailureCategory`と`Text`と`TextMap Text`を受け取り、`FailureStatus`を返します。
関数`spliceErrorId`は、`Text`を受け取り、`Text`を返します。
関数`checkTransferConstraints`は、`Transfer`と`TransferSummary`と`TransferConfigV2 unit`を受け取り、制約を満たさない時の`FailureStatus`か、`()`を`Either`で返します。

次の図Cでは、2つの一覧の5つずつの名前を、表の並びで足して追います。
関数の枝の名前は、関数の名前から、先頭のmkと末尾のFailureを除いた形です。
この図では、2つの一覧の対応を線にしません。

```dragon
mind 送金が失敗する理由

step 無効な理由の型
  say 送金の失敗に関わる名前の1つ目は、無効な理由の型です。
  idea root as "送金の失敗" [color: slate]
  idea g1 as "無効な理由" of root [color: blue]
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 無効な理由の5つの形
  say 無効な理由の型は、5つの形を持ちます。
  idea a1 as "ITR_InsufficientFunds" of g1 [color: rose]
  idea a2 as "ITR_UnknownSynchronizer" of g1 [color: rose]
  idea a3 as "ITR_InsufficientTopupAmount" of g1 [color: rose]
  idea a4 as "ITR_Other" of g1 [color: rose]
  idea a5 as "ExtInvalidTransferReason" of g1 [color: rose]
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]

step 失敗の状態を返す5つの関数
  say 2つ目は、失敗の状態を返す5つの関数です。枝の名前は、関数の名前から先頭のmkと末尾のFailureを除いた形です。
  idea g2 as "失敗の状態" of root [color: blue]
  idea b1 as "UnknownSynchronizer" of g2 [color: rose]
  idea b2 as "InsufficientTopupAmount" of g2 [color: rose]
  idea b3 as "MaximumInputsExceeded" of g2 [color: rose]
  idea b4 as "MaximumOutputsExceeded" of g2 [color: rose]
  idea b5 as "InsufficientFunds" of g2 [color: rose]
  source CantonのSplice.AmuletRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-amulet/splice-amuletrules]
```

## 次に読む頁

次の頁「受け手が前もって受け取りを許す」は、受け手が`TransferPreapproval`を作り、更新し、取り消して、個々のtransfer offerを承認せずにCanton Coinを受ける流れを追います。

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

## 出典

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-fees
