Designating any party in a list of parties as Controller

Hi,

I have a template with a list of parties. How can I allow any one of those parties to be able to exercise a choice, and pass that party to the resulting contract?

Example below:

template MyTemplate
  with 
    operator: Party 
    contacts : [Party]
    name: Text
  where 
    signatory operator 
    observer contacts 

    controller any one of the contacts can
      DoSomething: ContractId SomeProposal 
        with 
          newName : Text
        do 
          create SomeProposal with name = newName, operator, (contact who exercised the choice) 

template SomeProposal
  with 
    operator: Party 
    name: Text 
    contact : Party 
  where 
    signatory contact 

If there is another way to accomplish these things instead, that’s welcome too.

Thanks!

2 Likes

Can you do something like this using the dynamic choice construct?

   choice DoSomething : ContractId SomeProposal
     with
       contact : Party
       newName : Text
     controller contact
        do
          assertMsg "is not a contact" $ contact `elem` contacts
          create SomeProposal with name = newName, operator, contact
          
6 Likes

Great answer @matt!

2 Likes

Thank you Matt! This should work for me.

1 Like