What means a Party being a 'Witness' of a contract and what are its implications?

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:

Screenshot 2021-02-24 at 17.25.45

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
    operator : Party
    holder : Party
    signatory operator, holder
    key (operator, holder) : (Party, Party)
    maintainer key._1

    controller holder can
      nonconsuming ProposeAssetTransfer : ContractId AssetTransferProposal
          receiver : Party
          assetCid : ContractId Asset
          exercise assetCid ProposeTransfer with receiver
      nonconsuming AcceptAssetTransfer : ContractId Asset
          assetTransferProposalCid : ContractId AssetTransferProposal
          exercise assetTransferProposalCid AssetTransferProposal_Accept

template Asset
    issuer : Party
    owner : Party
    symbol : Text
    quantity : Decimal
    signatory issuer, owner

    controller owner can
        ProposeTransfer : ContractId AssetTransferProposal
        receiver : Party
        create AssetTransferProposal with receiver, asset = this, assetCid = self

template AssetTransferProposal
    receiver : Party
    asset : Asset
    assetCid : ContractId Asset
    signatory asset.owner, asset.issuer

    controller receiver can
      AssetTransferProposal_Accept : ContractId Asset
          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
1 Like

This means that Alice saw the creation of the new contract (#8:2) because she was a party to the old contract (#6:2) at the time it was consumed by Bob exercising AcceptAssetTransfer on HolderRole. The implications are that Alice could see that Bob became the new owner of Asset but will not see any future events that involve Asset such as it being archived as a result of sending the asset to another Party.

Additionally even though Alice saw/witnessed the creation of the new contract she cannot query for it after the one time event where she witnessed it.

Sometimes the docs are a bit hard to search so here’s some relevant links:


As an aside do you intend to disclose every Asset Proposal/Transfer to an operator on the HolderRole template via the same witnessing discussed above?

At the moment the operator on the HolderRole template can witness the transfer of every Asset and creations of AssetProposal performed through this contract if parties on the ledger choose to use it. However parties on the ledger can also create these contracts and exercise choices on them by exercising ProposeTransfer and AssetTransferProposal_Accept directly instead of using the HolderRole.

Thank you very much, @anthony!

Regarding your question, the idea of the exercise is what you’ve said: use the HolderRole to exercise the choices on Assets.

1 Like