Hi to all, I’m new to Daml and have been doing some exercises with it.
One of the exercises involved the transfer of an Asset contract from a Party to another one. Everything works correctly, but I’ve noticed that the owner of the previous Asset contract is marked as ‘Witness’ of the new Asset contract and was intrigued with that:
What does it means a Party being a ‘Witness’ of a contract and what are its implications? I didn’t found an answer for it in the documentation…
Here is some of the code I’ve used. I’ve applied the propose-accept pattern.
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