1

I have five parties so called A,B,C,D and E. Party A defined as signatory party and rest four parties are controllers, but my requirement is any once party can act as controller but i don't know exactly which party would be controller, How could i achieve this? my tries:

controller[b,c,d,e] can Approve : ContractId Test with ... getting error says require authorizers b,c,d,e but only b given

I want any party out of four(b,c,d,e) can exercise choice "Approve". Please help me

Thank you

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
irfan baba
  • 21
  • 1

1 Answers1

1

controller [b, c, d, e] requires all four parties to be controllers rather than one of the four. To allow for the latter, you can make use of a feature called flexible controllers. This allows you to define the controller with the choice argument in scope. You can then check in the choice itself, that the party is one of the four you want. Here is a full example, note that we make the other parties observers explicitly, the controller syntax usually does this implicitly for you but the flexible syntax used here does not do that automatically.

module Main where

import Daml.Script

template T
  with
    a : Party
    b : Party
    c : Party
    d : Party
    e : Party
  where
    signatory a
    observer [b, c, d, e]
    choice Approve : ()
      with
        actor : Party
      controller actor
      do assert (actor `elem` [b, c, d, e])
         pure ()

test = script do
  a <- allocateParty "a"
  b <- allocateParty "b"
  c <- allocateParty "c"
  d <- allocateParty "d"
  e <- allocateParty "e"
  cid <- submit a $ createCmd (T a b c d e)
  submit b $ exerciseCmd cid (Approve b)
cocreature
  • 801
  • 5
  • 5