# Scanで報酬とtrafficを確かめる

> roundごとの報酬の会計、trafficの消費と購入、validatorのliveness、送金の状態を、Scanで確かめる呼び方を追います。エンドポイントは本文、図は読み方と一覧を見ます。

- URL: https://cardene.dev/diagrams/canton-scan-rewards-traffic
- 公開日: 2026-11-23
- 更新日: 2026-11-23
- トピック: Blockchain
- タグ: Canton
- 親の図解: [Scanが返すネットワークの状態](https://cardene.dev/diagrams/canton-scan-network-view.md): SVのノードが出すScan APIから、ネットワークの構成と今の状態と統治と、保有とANSと報酬とtrafficの状態を引く呼び方を、7頁に分けて追います。

Scanは、報酬とtrafficとvalidatorの活動を確かめるエンドポイントも出します。
この頁では、閉じたroundの後始末と、roundごとの報酬の会計と、trafficの消費と購入と、validatorのlivenessと、送金の状態を、Scanでどう確かめるかを追います。
エンドポイントと返る値は本文が持ち、図Aはtrafficの読み方を、図Bは返る情報の一覧を示します。

前の頁「ANSの名前を作って引く」では、ANSのエントリーを作って引く呼び方を見ました。

https://cardene.dev/diagrams/canton-ans-entries

roundごとの報酬の引換券は、頁「roundごとに報酬の引換券を作る」で見ました。

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

CIP-0104のtrafficに基づくアプリの報酬と、minting allowanceは、頁「trafficでアプリの報酬を決める」で見ました。

https://cardene.dev/diagrams/canton-traffic-app-rewards

trafficの残高と買い足しは、頁「trafficの残高が引かれて尽きる」と頁「trafficを買い足す」で見ました。

https://cardene.dev/diagrams/canton-traffic-balance

https://cardene.dev/diagrams/canton-traffic-topup

## 閉じたroundの後始末を引く

`GET /v0/closed-rounds`は、つながるSpliceのネットワークの台帳の上で、閉じた後の処理がまだ残るclosed mining roundを、全て返します。
roundの番号の小さい順に並びます。

応答の必須の`rounds`は、`Contract`の配列で、各要素は、Damlのtemplate`Splice.Round:ClosedMiningRound`のコントラクトです。
処理していない報酬が残るか、`Splice.DsoRules:Confirmation`が欠けているroundごとに、1件あります。
このエンドポイントが普通は空を返すことは、頁「開いたroundとDSOの規則を引く」で見ました。

https://cardene.dev/diagrams/canton-scan-current-state

## 報酬の会計をroundごとに確かめる

`/v0/internal/reward-accounting-process`の下のエンドポイントは、SVのノードの内部のAPIです。
CIP-0104に沿い、変わることがあります。
版0.6.5で、`/v0/reward-accounting-process/...`から、この下へ移りました。

エンドポイントは、次の表の4つです。

| エンドポイント | 返す物 |
|---|---|
| `GET /v0/internal/reward-accounting-process/rounds/earliest-available` | CIP-0104の報酬の会計の活動の記録がそろった、最も早いroundを、int64型の`earliest_round`で返す。404は`error`を返す |
| `GET /v0/internal/reward-accounting-process/rounds/:round_number/activity-totals` | int64型の`round_number`のroundの、CIP-0104のroundごとの活動の合計を返す。版0.6.0で足され、版0.6.9と版0.10.2で変わった |
| `GET /v0/internal/reward-accounting-process/rounds/:round_number/root-hash` | 与えたroundについて計算した、rootのハッシュを返す。版0.6.0で足された |
| `GET /v0/internal/reward-accounting-process/rounds/:round_number/batches/:batch_hash` | 16進数の文字列で表した`batch_hash`が指す、報酬のbatchの中身を返す。版0.6.0で足された |

`activity-totals`の応答は、次の表の3つの形のどれかで、どれも`status`を持ちます。

| 形 | 意味 |
|---|---|
| `RewardAccountingActivityTotalsOk` | 合計が出た |
| `RewardAccountingActivityTotalsUndetermined` | まだ決まらない |
| `RewardAccountingActivityTotalsCannotProvide` | 出せない |

`RewardAccountingActivityTotalsOk`の形は、`status`に加えて、次の欄を全て持ちます。
活動の重みの`total_app_activity_weight`と`total_asset_activity_weight`と、roundの番号の`round_number`と、件数の`active_parties_count`と`activity_records_count`と`rewarded_app_provider_parties_count`は、どれも整数です。
報酬の合計と発行の比率の7つの欄は、次の表のとおりです。

| 欄 | 中身 |
|---|---|
| `total_app_reward_from_app_activity` | このroundで、アプリの活動から得た報酬の合計。閾値を下回った分も数える |
| `total_app_reward_from_asset_activity` | このroundで、資産の活動から得た報酬の合計。閾値を下回った分も数える |
| `issuance_per_featured_app_activity` | アプリの活動で、burnしたAmuletあたりにmintしたAmuletの比 |
| `issuance_per_featured_asset_activity` | 資産の活動で、burnしたAmuletあたりにmintしたAmuletの比 |
| `total_app_reward_minting_allowance` | このroundで、アプリの提供者に与えたminting allowanceの合計。アプリの活動と資産の活動の報酬を合わせた値 |
| `total_app_reward_thresholded` | 設定したアプリの報酬の閾値を下回ったので、burnされたminting allowanceの合計 |
| `total_app_reward_unclaimed` | 活動あたりのアプリの報酬の上限のため、このroundでアプリの提供者に割り当てられなかった、アプリの報酬の合計 |

`root-hash`の応答は、`RewardAccountingRootHashOk`と`RewardAccountingRootHashUndetermined`と`RewardAccountingRootHashCannotProvide`のどれかです。
`RewardAccountingRootHashOk`は、`status`と`round_number`と、16進数の文字列にした`root_hash`を持ちます。
後の2つは、`status`だけを持ちます。

batchの中身は、木の途中の節なら、子のbatchのハッシュの並びで、`BatchOfBatches`の`child_hashes`です。
末端の節なら、minting allowanceの並びで、`BatchOfMintingAllowances`の`minting_allowances`です。

応答の`batch_type`が、`BatchOfBatches`と`BatchOfMintingAllowances`のどちらかを示します。
`minting_allowances`の各要素は、`provider`と`amount`を持ちます。
404は、エラーの内容を持つ必須の欄`error`を含むJSONを返します。

:::details JSON
JSONは、データを文字で表すための形式で、Webのプログラムどうしのデータのやり取りに広く使われています。
:::

## featured appの権利と未請求の引換券を引く

featured appの権利を引くエンドポイントは、次の表の4つです。
featured app rightは、頁「活動の印で報酬を得る」で見ました。

https://cardene.dev/diagrams/canton-featured-app

| エンドポイント | 返す物 |
|---|---|
| `GET /v0/featured-apps` | DSOに登録された、台帳の上の`FeaturedAppRight`を全て、`Contract`の配列`featured_apps`で返す |
| `GET /v0/featured-apps/:provider_party_id` | パスの`provider_party_id`がDSOに登録された`FeaturedAppRight`を持てば、`featured_app_right`で返し、持たなければ空にする |
| `GET /v0/featured-apps/by-contract-id/:contract_id` | `FeaturedAppRight`のコントラクトをコントラクトIDで引き、見つかれば`featured_app_right`を返し、見つからなければ空を返す。版0.6.0で足された |
| `GET /v0/featured-apps/by-provider/:provider_party_id` | 与えた提供者の`FeaturedAppRight`のコントラクトを全て、`featured_apps`で返す。版0.6.0で足された |

`GET /v0/unclaimed-development-fund-coupons`は、まだ請求されていないDevelopment Fundの引換券を、全て返します。
Development Fundは、頁「Development Fundを配る」で見ました。

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

引換券は、Damlのtemplate`Splice.Amulet:UnclaimedDevelopmentFundCoupon`のコントラクトで、引換券1件につき1要素の、`ContractWithState`の配列に入ります。
500は、エラーの内容を持つ必須の欄`error`を含むJSONを返します。

## trafficの消費と購入を確かめる

`GET /v0/domains/:domain_id/members/:member_id/traffic-status`は、要求の時点の台帳の状態に従って、Sequencerが報告するmemberのtrafficの状態を返します。
パスの`domain_id`は、trafficを調べるSynchronizerのIDです。
パスの`member_id`は、調べるParticipant NodeかMediatorで、`code::id::fingerprint`の形で書き、`code`は`PAR`か`MED`です。

応答の`traffic_status`は、次の表の3つの値を持ちます。

| 欄 | 中身 |
|---|---|
| `actual`の`total_consumed` | Synchronizerの上で消費した、extra trafficの総量 |
| `actual`の`total_limit` | 今のextra trafficの上限 |
| `target`の`total_purchased` | 買ったextra trafficの総量で、単位はbyte |

買った分が上限に組み込まれるまで時間がかかるので、`total_purchased`は、`actual`の上限を超えることがあります。
extra trafficの買い足しは、`total_limit`が`total_purchased`に一致した時に終わります。
400と404と500は、エラーの内容を持つ必須の欄`error`を含むJSONを返します。

## validatorのlivenessを確かめる

`GET /v0/validators/validator-faucets`は、要求の時点の台帳の状態に従って、livenessの活動の統計を返します。
livenessとfaucetは、頁「licenseで活動を報告する」で見た、validatorの活動の記録です。

https://cardene.dev/diagrams/canton-validator-license

統計が数えるのは、validatorがfaucetを集めたroundです。
統計を返すのは、引数のうち、有効に加えられたvalidatorだけです。
版0.10.0で変わりました。

クエリの`validator_ids`は、必須のvalidatorのparty IDの並びで、引数1つに1つのIDを書き、最大1000件です。
加えられたvalidatorに合わないparty IDは、無視します。

応答の`validatorsReceivedFaucets`は、有効な加入のlicenseを持つと分かったvalidatorの統計の配列で、validator1つにつき1件です。
並びは、引数の順と関係ありません。
各統計の欄は、次の表のとおりです。

| 欄 | 中身 |
|---|---|
| `validator` | 必須。統計を持つ、加えられたvalidatorのparty ID |
| `numRoundsCollected` | validatorがfaucetを集めたroundの数。`numRoundsCollected + numRoundsMissed = lastCollectedInRound - firstCollectedInRound + 1`が必ず成り立つ |
| `numRoundsMissed` | `firstCollectedInRound`と`lastCollectedInRound`の間で、validatorが活動していなかったか、利用できなかったために、faucetを集められなかったroundの数。多くても`max(0, lastCollectedInRound - firstCollectedInRound - 1)` |
| `firstCollectedInRound` | faucetを集め始めたround |
| `lastCollectedInRound` | 最も新しく集めたround |

`firstCollectedInRound`と`lastCollectedInRound`のどちらのroundでも、validatorは必ずlivenessを記録しています。
1つのroundでしか集めていなければ、2つは等しくなります。
400と404は、エラーの内容を持つ必須の欄`error`を含むJSONを返します。

## 送金の状態を確かめる

Scanは、送金コマンドと事前承認の状態も、次の表の3つのエンドポイントで返します。
送金コマンドは`TransferCommand`の、事前承認は`TransferPreapproval`のコントラクトです。
Scan Proxyで同じ状態を引く呼び方は、前の頁「保有とANSと送金の状態を引く」で見ました。

https://cardene.dev/diagrams/canton-scan-network-state

| エンドポイント | 返す物 |
|---|---|
| `GET /v0/transfer-command-counter/:party` | 受け取る側のpartyで`TransferCommandCounter`を引き、`transfer_command_counter`を`ContractWithState`で返す。見つからなければ404で`error`を返す |
| `GET /v0/transfer-command/status` | クエリの必須の`sender`と、int64型で必須の`nonce`を指定すると、その組に合う送金コマンドの状態を、100件を上限に返す |
| `GET /v0/transfer-preapprovals/by-party/:party` | 受け取る側のpartyで`TransferPreapproval`を引き、`transfer_preapproval`を`ContractWithState`で返す。見つからなければ404で`error`を返す |

`transfer-command/status`の応答は、必須の`transfer_commands_by_contract_id`で、`TransferCommandMap`型です。
`sender`と`nonce`に合う送金コマンドのコントラクトIDごとに、`contract`と現在の`status`を持ちます。
404は、エラーの内容を持つ`error`を返します。

## 買い足したtrafficが上限に届くまで

図Aは、アプリとScanを並べます。
段を送ると、trafficの状態を頼み、買った分が上限に組み込まれるまでの読み方を追えます。
この図の2回目の問い合わせは、後で一致を確かめられた一例です。
問い合わせの回数と、間にどれだけ時間が空くかは、示しません。

```dragon
sequence 買い足したtrafficの確かめ方

box APP as アプリ [note: trafficを確かめる側, color: rose, icon: app]
box SCAN as Scan [note: SVのノードの部品, color: blue, icon: server]

step trafficの状態を頼む
  say SynchronizerのIDとmemberのIDを渡すと、Sequencerが報告するmemberのtrafficの状態が返ります。応答は、消費したextra trafficの総量と、今の上限と、買った総量を持ちます。
  APP -> SCAN: SynchronizerとmemberのIDを渡す
  SCAN -> APP: 消費と上限と買った総量を返す
  source CantonのScan APIのGET /v0/domains/:domain_id/members/:member_id/traffic-status [url: https://docs.canton.network/reference/splice-scan-api/get-v0domains:domain_idmembers:member_idtraffic-status]

step 買った総量が上限を超える
  say 買った分が上限に組み込まれるまで時間がかかるので、買った総量は、今の上限を超えることがあります。
  act APP: 買った総量が上限より大きいと読む
  source CantonのScan APIのGET /v0/domains/:domain_id/members/:member_id/traffic-status [url: https://docs.canton.network/reference/splice-scan-api/get-v0domains:domain_idmembers:member_idtraffic-status]

step しばらくして頼み直す
  say 買い足しが終わったかは、同じ状態を、しばらくして頼み直して確かめます。一致していない間は、まだ終わったと言えません。
  APP -> SCAN: 同じ状態を頼み直す
  SCAN -> APP: 消費と上限と買った総量を返す
  source CantonのScan APIのGET /v0/domains/:domain_id/members/:member_id/traffic-status [url: https://docs.canton.network/reference/splice-scan-api/get-v0domains:domain_idmembers:member_idtraffic-status]

step 上限と買った総量が一致する
  say この例では、頼み直した応答で、今の上限が買った総量に一致しました。extra trafficの買い足しは、この一致で終わると読めます。
  act APP: 一致したので買い足しが終わったと読む
  source CantonのScan APIのGET /v0/domains/:domain_id/members/:member_id/traffic-status [url: https://docs.canton.network/reference/splice-scan-api/get-v0domains:domain_idmembers:member_idtraffic-status]
```

## Scanで確かめる状態を並べる

図Bは、この頁で確かめる状態を、6つの枝に分けて並べます。
段を送ると、枝を1つずつ足せます。
図は、返る情報を並べます。
対応するエンドポイントは、上の表と本文にあります。

```dragon
mind Scanで確かめる報酬とtraffic

step 閉じたround
  say 閉じた後の処理がまだ残るroundは、番号の小さい順に引けます。
  idea root as "Scanで確かめる状態" [color: slate]
  idea c1 as "閉じたround" of root [color: blue]
  idea c2 as "後始末が残るround" of c1 [color: blue]
  source CantonのScan APIのGET /v0/closed-rounds [url: https://docs.canton.network/reference/splice-scan-api/get-v0closed-rounds]

step 報酬の会計
  say 報酬の会計は、記録がそろった最も早いroundと、roundごとの活動の合計と、rootのハッシュと、batchの中身を引けます。
  idea a1 as "報酬の会計" of root [color: blue]
  idea a2 as "最も早いround" of a1 [color: blue]
  idea a3 as "活動の合計" of a1 [color: blue]
  idea a4 as "rootのハッシュ" of a1 [color: blue]
  idea a5 as "batchの中身" of a1 [color: blue]
  source CantonのScan APIのGET /v0/internal/reward-accounting-process/rounds/earliest-available [url: https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processroundsearliest-available]
  source CantonのScan APIのGET /v0/internal/reward-accounting-process/rounds/:round_number/activity-totals [url: https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processrounds:round_numberactivity-totals]
  source CantonのScan APIのGET /v0/internal/reward-accounting-process/rounds/:round_number/root-hash [url: https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processrounds:round_numberroot-hash]
  source CantonのScan APIのGET /v0/internal/reward-accounting-process/rounds/:round_number/batches/:batch_hash [url: https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processrounds:round_numberbatches:batch_hash]

step 報酬の権利と引換券
  say 続いて、featured appの権利と、まだ請求されていないDevelopment Fundの引換券を引けます。
  idea f1 as "報酬の権利と引換券" of root [color: blue]
  idea f2 as "featured appの権利" of f1 [color: blue]
  idea f3 as "未請求の引換券" of f1 [color: blue]
  source CantonのScan APIのGET /v0/featured-apps [url: https://docs.canton.network/reference/splice-scan-api/get-v0featured-apps]
  source CantonのScan APIのGET /v0/unclaimed-development-fund-coupons [url: https://docs.canton.network/reference/splice-scan-api/get-v0unclaimed-development-fund-coupons]

step traffic
  say さらに、memberのtrafficの消費と上限と、買った総量を引けます。
  idea t1 as "traffic" of root [color: blue]
  idea t2 as "消費と上限" of t1 [color: blue]
  idea t3 as "買った総量" of t1 [color: blue]
  source CantonのScan APIのGET /v0/domains/:domain_id/members/:member_id/traffic-status [url: https://docs.canton.network/reference/splice-scan-api/get-v0domains:domain_idmembers:member_idtraffic-status]

step validatorのliveness
  say validatorのlivenessは、faucetを集めたroundと、集められなかったroundの統計で引けます。
  idea v1 as "validatorのliveness" of root [color: blue]
  idea v2 as "集めたround" of v1 [color: blue]
  idea v3 as "集められなかったround" of v1 [color: blue]
  source CantonのScan APIのGET /v0/validators/validator-faucets [url: https://docs.canton.network/reference/splice-scan-api/get-v0validatorsvalidator-faucets]

step 送金の状態
  say 最後に、送金コマンドの状態と、そのcounterと、事前承認を引けます。
  idea s1 as "送金" of root [color: blue]
  idea s2 as "送金コマンドの状態" of s1 [color: blue]
  idea s3 as "送金コマンドのcounter" of s1 [color: blue]
  idea s4 as "事前承認" of s1 [color: blue]
  source CantonのScan APIのGET /v0/transfer-command/status [url: https://docs.canton.network/reference/splice-scan-api/get-v0transfer-commandstatus]
  source CantonのScan APIのGET /v0/transfer-command-counter/:party [url: https://docs.canton.network/reference/splice-scan-api/get-v0transfer-command-counter:party]
  source CantonのScan APIのGET /v0/transfer-preapprovals/by-party/:party [url: https://docs.canton.network/reference/splice-scan-api/get-v0transfer-preapprovalsby-party:party]
```

## 出典

https://docs.canton.network/reference/splice-scan-api/get-v0closed-rounds

https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processroundsearliest-available

https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processrounds:round_numberactivity-totals

https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processrounds:round_numberroot-hash

https://docs.canton.network/reference/splice-scan-api/get-v0internalreward-accounting-processrounds:round_numberbatches:batch_hash

https://docs.canton.network/reference/splice-scan-api/get-v0featured-apps

https://docs.canton.network/reference/splice-scan-api/get-v0featured-apps:provider_party_id

https://docs.canton.network/reference/splice-scan-api/get-v0featured-appsby-contract-id:contract_id

https://docs.canton.network/reference/splice-scan-api/get-v0featured-appsby-provider:provider_party_id

https://docs.canton.network/reference/splice-scan-api/get-v0unclaimed-development-fund-coupons

https://docs.canton.network/reference/splice-scan-api/get-v0domains:domain_idmembers:member_idtraffic-status

https://docs.canton.network/reference/splice-scan-api/get-v0validatorsvalidator-faucets

https://docs.canton.network/reference/splice-scan-api/get-v0transfer-command-counter:party

https://docs.canton.network/reference/splice-scan-api/get-v0transfer-commandstatus

https://docs.canton.network/reference/splice-scan-api/get-v0transfer-preapprovalsby-party:party
