Parse error on input ‘<-’

template PersonalContract
  with
    signat : Party
    h : Party
    number : Int
    

  where
    signatory  signat

    controller hos can
      ExtraFunc : Optional (ContractId Demo)
        do
                  
          if number == 1
          then
            **temp <- create Demo with**
              signat = signat
              h = h

            return (Some temp)
          else
            return None

                      
          


template Demo
  with
    signat : Party
    h : Party

  where
    signatory signat

Hi @axnbl
You’ll need a do after the then

    controller hos can
      ExtraFunc : Optional (ContractId Demo)
        do
          if number == 1
          then do
            temp <- create $ Demo with signat = signat, h = h
            return (Some temp)
          else
            return None

2 Likes

But it will create the Demo Contract. I dont want to create it unless or until number == 1. Is there any other way to do that?

That’s exactly what @drsk’s example will do. Adding the do does no tchange the fact that it will only be created if the number is 1.

2 Likes

ohh okay… got it

1 Like

2 posts were split to a new topic: Can we put do blocks directly in templates?