Transferring Data From One templet to another

Hi ,
I am working On an small Usecase For which The templates looks like I am able to connet 2-3 but how to connet 1-2 templets?Any suggestions

(1 )template Onboarding
  with
    csd : Party
    
    issuer : Party
  where
    
    signatory issuer
    
    controller issuer can
      CreateMeeting : ContractId Onboarding
        with 
         title : Text
         details : Text
         regulator : Party
 
        do 
         create Onboarding
          with 
          csd
          issuer
 
(2)template Meeting
  with
    issuer : Party
    csd : Party
    title : Text
    details : Text
    observers : [Party]
  where 
    signatory csd
    observer observers
    controller csd can
             SendEntitlementNotification : ContractId EntitlementNotification
                with   
                 votingParty : Party
                 noOfVotes : Int
                do
                 create EntitlementNotification with
                   meeting = this
                   votingParty
                   noOfVotes
                   observers 
(3)template  EntitlementNotification
 with
   
        meeting :  Meeting
        votingParty : Party
        noOfVotes : Int
        observers : [Party]
      where
         signatory meeting.csd
1 Like

Hi @Svv, welcome to the forum! I assume by “connect” you are asking for a way to actually create a Meeting from the CreateMeeting choice?

Here is a minimal example of this together with a test script:

template Onboarding
  with
    csd : Party
    issuer : Party
  where
    signatory issuer

    controller csd can
      CreateMeeting : ContractId Meeting
        with
         title : Text
         details : Text
         regulator : Party
        do
         create Meeting
          with
            csd
            issuer
            title
            details
            observers = [regulator]

test = do
  alice <- allocateParty "Alice"
  bob <- allocateParty "Bob"
  charlie <- allocateParty "Charlie"
  cid <- submit alice $ createCmd (Onboarding bob alice)
  submit bob $ exerciseCmd cid CreateMeeting with
    title = "title"
    details = "details"
    regulator = charlie
  pure ()

There are a few points worth noting:

  1. Creating a meeting requires authorization from csd so they need to be the controller on the choice.
  2. Slightly related to that you might want to make the issuer a signatory on Meeting. Otherwise csd can create Meeting directly without going through Onboarding.
  3. I’m not quite sure what the regulator’s role is. I just added them as an observer in Meeting but make sure this is what you actually want.
1 Like

But why i am getting error for this Contract? Any suggestions

(3)template  EntitlementNotification
 with
   
        meeting :  Meeting
        votingParty : Party
        noOfVotes : Int
        observers : [Party]
  where
         signatory meeting.csd
         observer observers
         controller votingParty can
          SendMeetingInstructions : ContractId MeetingInstructions
            with 
              instructions : Text
              localCustodian : Party
            do 
             create MeetingInstructions with 
                meeting 
                votingParty 
                localCustodian 
                instructions               
                observers =[localCustodian, votingParty]               
(4)template MeetingInstructions
  with
      meeting : Meeting
      votingParty : Party
      localCustodian : Party
      instructions : Text                
      observers : [Party]      
    
   where
         signatory localCustodian
         observer observers
1 Like

Can you show us the error you are seeing?

1 Like

Like if try to send EntitlementNofication. Contract is updating to send meeting instructions but while doing choice send meetingInstructions in templet -3 contract is not getting created

1 Like

You are only allowed to do this, according to your current code, if votingParty = localCustodian (edit: or meeting.csd = localCustodian).

Take a close look at the signatory for MeetingInstructions. Being a signatory means you “agree” to a contract. Now, suppose that when votingParty exercises SendMeetingInstructions, localCustodian argument doesn’t match votingParty. That means that the votingParty can effectively force the localCustodian to agree to a contract, without their permission! The only way that can be allowed is if localCustodian and votingParty are the same, but I suspect that this is not what you intended when you wrote this code.

You can take a look at part of our introduction to Daml to learn more about signatories and what they mean for contracts, such as how to design workflows and use common design patterns to make sure you are gathering permission from appropriate signatories for each contract you wish to create.

For this and other issues you may want help with in the future, users of this forum can help you faster if you copy-and-paste the actual error you are getting, exactly as Daml Studio or whatever other tool reports it.

1 Like

Like how can i add all partys to observers from the choice entitlement notification Any idea liike i have to add partys like localCustodian,globalCustodian,serviceprovider these three are the party i should add as observers


my code is like this

template Onboarding
  with
    csd : Party
    
    issuer : Party
   -- globalCustodian :  Party
  
    --localCustodian : Party
    --servicesProvider :Party
    
 
  where
    
    signatory issuer
    controller csd can
      CreateMeeting : ContractId Meeting
        with
         title : Text
         details : Text
         regulator : Party
        do
         create Meeting
          with
            csd
            issuer
            title
            details
           -- globalCustodian
            observers = [regulator]
 
template Meeting
  with
    issuer : Party
    csd : Party
    title : Text
    details : Text
    observers : [Party]
    --globalCustodian :  Party
  where 
    signatory csd
    --key (issuer, title) : AccountKey
   -- maintainer key._1
    observer observers
    controller csd can
             SendEntitlementNotification : ContractId EntitlementNotification
                with   
                 votingParty : Party
                 noOfVotes : Int
                do
                 create EntitlementNotification with
                   meeting = this
                   votingParty
                   noOfVotes
                   observers = []

                 
template  EntitlementNotification
 with
   
        meeting :  Meeting
        votingParty : Party
        noOfVotes : Int
        observers : [Party]

  where
         signatory meeting.csd
         observer observers
         controller votingParty can
          SendMeetingInstructions : ContractId MeetingInstructions
            with 
              instructions : Text
              localCustodian : Party
            do 
             create MeetingInstructions with 
                meeting 
                votingParty 
                localCustodian 
                instructions               
                observers =[localCustodian, votingParty]      
                         
template MeetingInstructions
  with
      meeting : Meeting
      votingParty : Party
      localCustodian : Party
      instructions : Text                
      observers : [Party]      
    
   where
         signatory votingParty
         observer observers
         controller votingParty can
           VoteExecution : ContractId ExecuteVote 
            do
              create ExecuteVote with
               localCustodian
               meeting
               observers = [localCustodian, votingParty]
               
               
template ExecuteVote
 with
  meeting : Meeting
  localCustodian : Party
  observers : [Party]
  
 where
  signatory localCustodian
  observer observers
  controller meeting.issuer can
    AcceptVote: ContractId VoteAcceptance
     do 
      create VoteAcceptance with
       observers
       meeting
 
template VoteAcceptance
  with 
   meeting : Meeting
   observers :[Party]
  where
   signatory meeting.issuer 

Any suggestions? l want to get result as shown in above picture

1 Like

Hi @Svv, I’m not quite following what you want to do. Can you walk us through a step by step guide starting from an empty legder which contracts you want to create and which choices should be exercised with which effects? Even better if you can turn that into a Daml Script that shows the workflow you are having trouble with.

1 Like