一方作为合同的“见证人”是什么意思,其含义是什么?
What means a Party being a ‘Witness’ of a contract and what are its implications?
我正在做一些练习来了解 Daml,其中一个练习涉及将资产从一方转移到另一方。一切正常,但我注意到之前资产合约的所有者被标记为新资产合约的“见证人”(在 Assets.Asset:Asset
,ID 为 #8:2
的合约有 Alice
标有 W
、Witness
).
我对此很感兴趣。一方作为合同的“见证人”是什么意思,它的含义是什么?我没有在文档中找到答案…
这是我使用过的一些代码。我已经应用了提议-接受模式。
template HolderRole
with
operator : Party
holder : Party
where
signatory operator, holder
key (operator, holder) : (Party, Party)
maintainer key._1
controller holder can
nonconsuming ProposeAssetTransfer : ContractId AssetTransferProposal
with
receiver : Party
assetCid : ContractId Asset
do
exercise assetCid ProposeTransfer with receiver
nonconsuming AcceptAssetTransfer : ContractId Asset
with
assetTransferProposalCid : ContractId AssetTransferProposal
do
exercise assetTransferProposalCid AssetTransferProposal_Accept
template Asset
with
issuer : Party
owner : Party
symbol : Text
quantity : Decimal
where
signatory issuer, owner
controller owner can
ProposeTransfer : ContractId AssetTransferProposal
with
receiver : Party
do
create AssetTransferProposal with receiver, asset = this, assetCid = self
template AssetTransferProposal
with
receiver : Party
asset : Asset
assetCid : ContractId Asset
where
signatory asset.owner, asset.issuer
controller receiver can
AssetTransferProposal_Accept : ContractId Asset
do
create asset with owner = receiver
assetTransferTest = script do
...
-- Transfer an Asset to another Party
assetTransferProposalCid <- submit alice do
exerciseByKeyCmd @HolderRole (operator, alice) ProposeAssetTransfer
with receiver = bob, assetCid = assetCid
-- Accept a transfer
submit bob do
exerciseByKeyCmd @HolderRole (operator, bob) AcceptAssetTransfer
with assetTransferProposalCid = assetTransferProposalCid
这意味着 Alice
看到了新合约 (#8:2
) 的创建,因为她是旧合约 (#6:2
) 在被消费时的一方Bob
在 HolderRole
上锻炼 AcceptAssetTransfer
。其含义是 Alice
可以看到 Bob
成为 Asset
的新所有者,但不会看到涉及 Asset
的任何未来事件,例如由于将资产发送给另一方。
此外,即使 Alice
saw/witnessed 新合同的创建,她也无法在她目睹的一次性事件后查询它。
有时文档有点难以搜索,所以这里有一些相关链接:
- A simple overview of the meaning of S, O, W, and D in the Script output
- The ledger privacy model
- A more detailed explanation on witnessing and divulgence
- An explanation of contract consumption in general
因为在我们的论坛上也有人同时问了这个问题further discussion may be located here。
我正在做一些练习来了解 Daml,其中一个练习涉及将资产从一方转移到另一方。一切正常,但我注意到之前资产合约的所有者被标记为新资产合约的“见证人”(在 Assets.Asset:Asset
,ID 为 #8:2
的合约有 Alice
标有 W
、Witness
).
我对此很感兴趣。一方作为合同的“见证人”是什么意思,它的含义是什么?我没有在文档中找到答案…
这是我使用过的一些代码。我已经应用了提议-接受模式。
template HolderRole
with
operator : Party
holder : Party
where
signatory operator, holder
key (operator, holder) : (Party, Party)
maintainer key._1
controller holder can
nonconsuming ProposeAssetTransfer : ContractId AssetTransferProposal
with
receiver : Party
assetCid : ContractId Asset
do
exercise assetCid ProposeTransfer with receiver
nonconsuming AcceptAssetTransfer : ContractId Asset
with
assetTransferProposalCid : ContractId AssetTransferProposal
do
exercise assetTransferProposalCid AssetTransferProposal_Accept
template Asset
with
issuer : Party
owner : Party
symbol : Text
quantity : Decimal
where
signatory issuer, owner
controller owner can
ProposeTransfer : ContractId AssetTransferProposal
with
receiver : Party
do
create AssetTransferProposal with receiver, asset = this, assetCid = self
template AssetTransferProposal
with
receiver : Party
asset : Asset
assetCid : ContractId Asset
where
signatory asset.owner, asset.issuer
controller receiver can
AssetTransferProposal_Accept : ContractId Asset
do
create asset with owner = receiver
assetTransferTest = script do
...
-- Transfer an Asset to another Party
assetTransferProposalCid <- submit alice do
exerciseByKeyCmd @HolderRole (operator, alice) ProposeAssetTransfer
with receiver = bob, assetCid = assetCid
-- Accept a transfer
submit bob do
exerciseByKeyCmd @HolderRole (operator, bob) AcceptAssetTransfer
with assetTransferProposalCid = assetTransferProposalCid
这意味着 Alice
看到了新合约 (#8:2
) 的创建,因为她是旧合约 (#6:2
) 在被消费时的一方Bob
在 HolderRole
上锻炼 AcceptAssetTransfer
。其含义是 Alice
可以看到 Bob
成为 Asset
的新所有者,但不会看到涉及 Asset
的任何未来事件,例如由于将资产发送给另一方。
此外,即使 Alice
saw/witnessed 新合同的创建,她也无法在她目睹的一次性事件后查询它。
有时文档有点难以搜索,所以这里有一些相关链接:
- A simple overview of the meaning of S, O, W, and D in the Script output
- The ledger privacy model
- A more detailed explanation on witnessing and divulgence
- An explanation of contract consumption in general
因为在我们的论坛上也有人同时问了这个问题further discussion may be located here。