Skip to content
CCPEDIAby Unity Nodes
App Development

Where exactly I can see what I define when using agreement keyword?

3 posts194 views2 likesLast activity Oct 2022

  1. cohen.avrahamOP

    G-d willing

    Hello,
    inside the where block I can define an agreement keyword. Where do I see it?
    https://docs.daml.com/daml/reference/templates.html#agreements

  2. Ben_M 1

    The AGREEMENT keyword as you stated is located within the WHERE codeblock, and allows you to enter in additional information that cannot be modelled in the actual contract.

    Take for example the House Painting scenario: I can offer to paint your House; you can accept my offer; I paint the house; You acknowledge that the task is done; You authorise payment or We go into mediation.

    All of those can be modelled directly in the contract, however what cannot be modelled in the contract is Me actually painting your House. The only way to do that is to use the AGREEMENT keyword and include in that codeblock a real contract stipulating the relevant and agreed to Terms&Conditions.

    Referring to the Getting Started — Daml SDK 2.4.0 documentation

    In the Basic Module Paint codeblock:

    module Paint where
    
    import Daml.Script
    import Iou
    
    template PaintHouse
      with
        painter: Party
        houseOwner: Party
      where
        signatory painter, houseOwner
        agreement
          show painter <> " will paint the house of " <> show houseOwner
    
    template OfferToPaintHouseByPainter
      with
        houseOwner: Party
        painter: Party
        bank: Party
        amount: Amount
      where
        signatory painter
        observer houseOwner
    
        choice AcceptByOwner : ContractId Iou
          with
            iouId : ContractId Iou
          controller houseOwner
          do
            iouId2 <- exercise iouId Transfer with newOwner = painter
            paint <- create $ PaintHouse with painter; houseOwner
            return iouId2
    

    Looking at the specific line show painter <> " will paint the house of " <> show houseOwner you can see a terse example, and note that the Signatory painter & houseOwner will have had their names taken from the With Parties section, and entered into the AGREEMENT.

    If you wanted to use the AGREEMENT field to stipulate specifics, you might modify it to something like the sample below, ensuring adherence to Daml contract alignment and the correct use for formatting:

    module Paint where
    
    import Daml.Script
    import Iou
    
    template PaintHouse
      with
        painter: Party
        houseOwner: Party
        houseAddress: Text
      where
        signatory painter, houseOwner
        agreement
          show painter <>
          " will perform the following service:
         
          Repaint a House, consisting of stages
    
          ,  1). Seal any holes using ABC Sealant
          ,  2). Waterblast & sand using 150/300/400 Grit abrasive paper
          ,  3). Apply 2 coats of an approved All-weather Sealant
          ,  4). Apply 4 coats of an approved All-weather Exterior paint, Colour: Grey
          ,  5). Remove all preparatory, painting and cleanup waste at own cost
          ,  6). Ensure no damage to any other chattel or asset onsite
          ,  7). Not use more that USD $5,000 in materials
          ,  8). Not take more than 3 calendar weeks or 150 human-hours of tracked Labor ($20 p/hr), whichever is less
          ,  9). Not to occur before June 10, 2022 and finish before August 18th, 2022
          ,  10). To take all reasonable precautions associated with housepainting
          ,  11). To submit all work for final inspection by a qualified contractor no later than August 19th, 2022 at the house of " <> show houseOwner show houseAddress
    
    template OfferToPaintHouseByPainter
      with
        houseOwner: Party
        painter: Party
        bank: Party
        amount: Amount
      where
        signatory painter
        observer houseOwner
    
        choice AcceptByOwner : ContractId Iou
          with
            iouId : ContractId Iou
          controller houseOwner
          do
            iouId2 <- exercise iouId Transfer with newOwner = painter
            paint <- create $ PaintHouse with painter; houseOwner
            return iouId2
    

    This AGREEMENT clause allows you to specify, internally to the Daml Contract, further Terms&Conditions that can only apply to and be potentially enforced, in the real world.

    Hope this helps, if not please reply.

  3. cohen.avraham 1

    G-d willing

    Thank @Ben_M for your detailed answer.