# walletのtokenの扱い

> walletを作る人が、Token Standardのtokenの残高と履歴を読み、transferを送って受け、保有を少なく保つ手順を、章の中の図解で追います。

- URL: https://cardene.dev/diagrams/canton-ext-wallet-token
- 公開日: 2026-11-24
- 更新日: 2026-11-24
- トピック: Blockchain
- タグ: Canton
- 親の図解: [Canton Networkの全体像](https://cardene.dev/diagrams/canton-network.md): トランザクションの中身を関わるpartyにだけ見せるCanton Networkについて、部品ごとの役割と、1つのトランザクションが部品の間をどう流れるかを段ごとに追います。
- 子の図解: [walletで残高と履歴を読む](https://cardene.dev/diagrams/canton-token-wallet-read.md): walletが、userのpartyを持つvalidatorのノードのJSON Ledger APIから、Token Standardの保有を読み、トランザクションの履歴を解いて取り出す手順を追います。
- 子の図解: [transferを受け取る2つの形](https://cardene.dev/diagrams/canton-wallet-transfer-kinds.md): Amuletのtransferが、2段で受け取る形と、事前承認による1段の形で、UTXOとlockをどう動かすかを、walletを作る人の目で追います。
- 子の図解: [walletからtokenを送る](https://cardene.dev/diagrams/canton-token-wallet-transfer.md): walletが、registryからfactoryを取り、Ledger APIでchoiceを実行してトークンのtransferを送り、1段で終わったかを結果から知る手順を追います。
- 子の図解: [holdingのUTXOを少なく保つ](https://cardene.dev/diagrams/canton-token-holding-merge.md): walletの提供者が、userのholdingのUTXOを少なく保つ方針と、MergeDelegationを用意して自動でまとめる手順を、資料の順に追います。

この章は、walletを作る人が、Token Standardのtokenを読み、送り、保有をまとめる手順を追います。
Token Standardの型は、章「Token StandardのDaml API」が追っているので、この章は型の中身を繰り返さず、walletからLedger APIとregistryへ何を送るかを書きます。
walletの仕組みは、前の章「Amuletの送金」と「Splice WalletとCNS」の頁が説明しています。

まず、walletが、userのpartyの保有を読み、トランザクションの履歴を解く手順を見ます。

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

次に、Amuletのtransferを、2段で受け取る形と、事前承認で1段で受け取る形に分け、保有とlockの動きを追います。

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

その次に、walletがregistryとLedger APIを使ってtokenのtransferを送り、受け、1段で終わったかを知る手順を追います。

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

最後に、walletの提供者が、userの保有の数を少なく保ち、`MergeDelegation`で自動でまとめる手順を追います。

https://cardene.dev/diagrams/canton-token-holding-merge

図の語は、それぞれの頁が説明します。

下の図は、walletとParticipant Nodeとregistryの順に置いた後、この章の4つの頁を、残高と履歴を読む、transferを受け取る形、tokenを送る、保有を少なく保つの順に置きます。
箱に頁の題が表示されたら、その題を押すと頁を開きます。

```dragon
architecture walletのtokenの扱い
group Top as walletのtokenの扱い [icon: net]
  box W as wallet [note: userのtokenを読み、送る, color: blue, icon: card]
  box N as Participant Node [note: userのpartyを持つvalidatorのノード, color: slate, icon: server]
  box R as registry [note: factoryを返す, color: rose, icon: server]
end
group Pages as この章の4つの頁 [color: blue, icon: card]
  box Rd as 残高と履歴を読む [note: 保有を読み、履歴を解く, icon: db, link: /diagrams/canton-token-wallet-read]
  box Kind as transferを受け取る形 [note: 2段と、Canton Coinの事前承認の1段, icon: refresh, link: /diagrams/canton-wallet-transfer-kinds]
  box Snd as tokenを送る [note: factoryを取り、choiceを実行する, icon: card, link: /diagrams/canton-token-wallet-transfer]
  box Mg as 保有を少なく保つ [note: 提供者が委任を使ってまとめる, icon: db, link: /diagrams/canton-token-holding-merge]
end

step walletのまわり
  say walletは、Participant NodeのLedger APIへ、保有と履歴の読み取りと、transferのchoiceの実行を要求します。walletは、transferを送る前に、registryにfactoryを求めます。
  W -> N: 読み取りと実行を頼む
  W -> R: factoryを求める
  source CantonのToken Standard [url: https://docs.canton.network/appdev/deep-dives/token-standard]
  source CantonのTransfer Instruction V2 [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-api-token-transfer-instruction-v2/splice-api-token-transferinstructionv2]
  source Cantonのsubmit-and-wait-for-transactionの参照 [url: https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait-for-transaction]
  source Cantonのexecuteandwaitfortransactionの参照 [url: https://docs.canton.network/reference/json-api-reference/post-v2interactive-submissionexecuteandwaitfortransaction]

step この章の4つの頁
  say 残高と履歴を読む頁は、保有を読み、履歴を解く手順を扱います。transferを受け取る形の頁は、2段の受け取りと、Canton Coinの事前承認で受け入れの操作を省く1段を扱います。tokenを送る頁は、factoryを取り、choiceを実行する手順を扱います。保有を少なく保つ頁は、userの委任がある時に、提供者の定期処理で保有をまとめる手順を扱います。
  source CantonのToken Standard [url: https://docs.canton.network/appdev/deep-dives/token-standard]
  source CantonのPreparing and Signing a Transaction [url: https://docs.canton.network/sdks-tools/sdks/wallet-sdk/guides/preparing-and-signing-a-transaction]
  source CantonのTransfer Types [url: https://docs.canton.network/sdks-tools/sdks/wallet-sdk/guides/transfer-types]
  source CantonのMergeDelegation [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-util-token-standard-wallet/splice-util-token-wallet-mergedelegation]
```

一番外では、walletが、Participant NodeのLedger APIへ、保有と履歴の読み取りと、transferのchoiceの実行を要求します。
walletは、transferを送る前に、registryにfactoryを求めます。

この章の4つの頁は、残高と履歴を読む頁、transferを受け取る形の頁、tokenを送る頁、保有を少なく保つ頁です。
transferを受け取る形の頁は、2段の受け取りと、Canton Coinで受け手の有効な事前承認を使う時に、受け手の受け入れの操作を省く1段を扱います。

保有を少なく保つ頁では、walletの提供者が、userごとの保有の数を、平均で約10個より少なく保つよう勧められています。
userが委任を設定している時は、提供者の定期処理が、委任を使って小さな保有をまとめます。

## 出典

https://docs.canton.network/appdev/deep-dives/token-standard

https://docs.canton.network/sdks-tools/sdks/wallet-sdk/guides/preparing-and-signing-a-transaction

https://docs.canton.network/sdks-tools/sdks/wallet-sdk/guides/transfer-types

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-util-token-standard-wallet/splice-util-token-wallet-mergedelegation

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

https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait-for-transaction

https://docs.canton.network/reference/json-api-reference/post-v2interactive-submissionexecuteandwaitfortransaction
