# Features announced to be deprecated: "controller first" choice syntax, contract key uniqueness - anything else?

**URL:** <https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077>\
**Category:** App Development\
**Created:** [March 8, 2022, 1:07pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077 "2022-03-08T13:07:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [March 8, 2022, 1:07pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/1 "2022-03-08T13:07:49Z")

</div>

Some features were announced to be deprecated together with the announcement of Daml 2.0. I have found two such features, is there anything else I have missed?

**"Controller first" choice syntax**

- The syntax `controller … can` will be deprecated in favor of the choice `X controller …` syntax. If the deprecated syntax is used then the following warning will be shown in the IDE:  
`The syntax 'controller ... can' is deprecated, it will be removed in a future version of Daml. Instead, use 'choice ... with ... controller' syntax. Note that 'choice ... with ... controller' syntax does not implicitly add the controller as an observer, so it must be added explicitly as one (or as a signatory).`

> **[Release of Daml 2.0](https://daml.com/release-notes/2.0.0?utm_source=foruml&utm_medium=direct&dpost=daml&_ga=2.228748380.1949471705.1646636818-715472163.1644829018)**
>
> Integrating Canton into Daml - introducing Canton-enabled drivers; Improvements in the developer experience to build and test distributed applications; Addition of the User Management Service; Supporting newer versions of dependencies

**Contract key uniqueness**

contract key uniqueness will soon be deprecated, as uniqueness can not be enforced among multiple domains. We encourage to build your models already anticipating this change.

[https://docs.daml.com/canton/usermanual/contract\_keys.html](https://docs.daml.com/canton/usermanual/contract_keys.html)

I guess with the deprecation of key uniqueness, some functions like `exerciseByKey` (used extensively in React UI examples for Daml) will also be deprecated.

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [April 29, 2022, 3:54pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/3 "2022-04-29T15:54:34Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [May 2, 2022, 6:35am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/4 "2022-05-02T06:35:07Z")

</div>

I’ve deleted my answer since it contained inaccuracies, I’ll let someone else write down an accurate answer, apologies for the confusion.

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [May 2, 2022, 6:38am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/5 "2022-05-02T06:38:11Z")

</div>

The only deprecations I’m aware off are the `controller … can` syntax and the ledger identity service.

Note that both of those are deprecated not removed, you can still use them for now and migrate away from them over time.

Contract key uniqueness is _not_ yet deprecated. In fact, it’s the only supported option atm since multi-domain Canton is not yet GA. It may still be useful to consider where you rely on contract key uniqueness to ease the migration later but for now uniqueness is the only option on GA ledgers.

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [May 2, 2022, 8:24am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/6 "2022-05-02T08:24:45Z")

</div>

Yes, thank you!

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [May 2, 2022, 8:25am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/7 "2022-05-02T08:25:23Z")

</div>

Thank you, Stefano!

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 14, 2022, 2:00pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/8 "2022-05-14T14:00:48Z")

</div>

Hey I have the same issue but didn’t understand how to fix it. could you please help me?

The syntax ‘controller … can’ is deprecated, it will be removed in a future version of Daml. Instead, use ‘choice … with … controller’ syntax. Note that ‘choice … with … controller’ syntax does not implicitly add the controller as an observer, so it must be added explicitly as one (or as a signatory).

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [May 14, 2022, 3:53pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/9 "2022-05-14T15:53:50Z")

</div>

@Nimra_Fatima can you share the example you’re having trouble adjusting?

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 15, 2022, 11:37am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/10 "2022-05-15T11:37:22Z")

</div>

I got this error in my .daml files

The syntax ‘controller … can’ is deprecated, it will be removed in a future version of Daml. Instead, use ‘choice … with … controller’ syntax. Note that ‘choice … with … controller’ syntax does not implicitly add the controller as an observer, so it must be added explicitly as one (or as a signatory).

please help me to fix this issue

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [May 15, 2022, 12:17pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/11 "2022-05-15T12:17:09Z")

</div>

Hi @Nimra_Fatima,

It’s difficult to give you more guidance than what’s already said in the error message without having access to your code. Can you share the template that produces that warning?

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 15, 2022, 12:54pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/12 "2022-05-15T12:54:45Z")

</div>

@Gary_Verhaegen

Payment.daml

module Payment where

template Payable  
with  
amount: Decimal  
currency: Text  
from: Party  
to: Party  
reference: Text  
where  
signatory from  
observer to

```
controller from can 
  ClaimPaid: ContractId PaymentClaim 
    with 
      transactionId: Text 
    do 
      create PaymentClaim with ..

```

template PaymentClaim  
with  
amount: Decimal  
currency: Text  
from: Party  
to: Party  
reference: Text  
transactionId: Text  
where  
signatory from

```
controller to can 
  Receive: ContractId Receipt 
    do 
      received <- getTime
      create Receipt 
        with ..

```

template Receipt  
with  
amount: Decimal  
currency: Text  
from: Party  
to: Party  
reference: Text  
transactionId: Text  
received: Time  
where  
signatory to, from

```
controller from can 
  Dismiss: () 
    do return ()

```

here is the code in which I got this error

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [May 15, 2022, 7:22pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/13 "2022-05-15T19:22:32Z")

</div>

Hi @Nimra_Fatima,

As the error message says, the `controller ... can` syntax is deprecated and needs to be replaced with `choice ... controller ...`. The two syntaxes are explained in [the documentation of choices](https://docs.daml.com/daml/reference/choices.html).

As a concrete example, this means replacing:

```haskell
  controller from can
    ClaimPaid: ContractId PaymentClaim 
      with 
        transactionId: Text 
      do 
        create PaymentClaim with ..

```

which is in "`controller` first" form, to the equivalent "`choice` first" form:

```haskell
  choice ClaimPaid : ContractId PaymentClaim
    with transactionId: Text
    controller from
    do
      create PaymentClaim with ..

```

which is the same choice but expressed with the `choice` keyword first.

The "`choice` first" form has a couple advantages:

- It can specificy the consuming behaviour of a choice.
- It can enable flexible controllers by having the controlling `Party` as an argument to the choice, as explained in [this old blog post](https://medium.com/daml-driven/daml-does-yoga-an-introduction-to-flexible-controllers-65ec08b34247).
- It’s not deprecated.

Importantly, while not all "`choice` first" choices can be translated to `controller` first" form, all "`controller` first" choices can easily be transformed to "`choice` first" by basically moving the `controller X` words a couple lines down, with the minor exception that when the controller was neither a signatory nor an observer, it needs to be manually added to the observers.

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 16, 2022, 3:49pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/14 "2022-05-16T15:49:21Z")

</div>

@Gary_Verhaegen Thank you so much Sir

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 16, 2022, 4:59pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/15 "2022-05-16T16:59:06Z")

</div>

Hey @Gary_Verhaegen  
can you tell me how to add controller keyword in nonconsuming choice

```
controller issuer can 
  nonconsuming MintToken: ContractId Token 
    with 
      description: Text 
      initialPrice: Decimal 
      currency: Text 
      royaltyRate: Decimal 
      thumbnail: Thumbnail
    do 
      issued <- getTime
      create Token
        with 
          lastPrice = initialPrice
          owner = issuer
          ..
```

---

<div class="post-metadata">

**Author:** ![a\_putkov](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/a_putkov/32/2971_2.png) [@a\_putkov](https://forum.canton.network/u/a_putkov)\
**Post date:** [May 16, 2022, 10:26pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/16 "2022-05-16T22:26:31Z")

</div>

> [@Nimra\_Fatima](#):
>
> ```haskell
> controller issuer can 
> nonconsuming MintToken: ContractId Token 
> with 
> description: Text 
> initialPrice: Decimal 
> currency: Text 
> royaltyRate: Decimal 
> thumbnail: Thumbnail
> do 
> issued <- getTime
> create Token
> with 
> lastPrice = initialPrice
> owner = issuer
> ..
> 
> ```

@Nimra_Fatima  
Here you go

```haskell
    nonconsuming choice MintToken: ContractId Token 
       with 
         description: Text 
         InitialPrice: Decimal 
         currency: Text 
         royaltyRate: Decimal 
         thumbnail: Thumbnail
      controller issuer
      do 
         issued <- getTime
         create Token
           with 
             lastPrice = initialPrice
             owner = issuer
             ..

```

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 17, 2022, 3:35am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/17 "2022-05-17T03:35:34Z")

</div>

@a_putkov I have already tried this but when I write controller then it gives me the error

```
nonconsuming choice MintToken: ContractId Token   
    with
      description: Text
      initialPrice: Decimal
      currency: Text
      royaltyRate: Decimal
    
    controller issuer
    do
      issued <- getTime
      create Token
        with
          lastPrice = initialPrice
          owner = issuer
          .. 

```

error: /home/nimra/private-nft/nft/daml/UserAdmin.daml:27:9: error:  
parse error on input ‘controller’parser

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [May 17, 2022, 6:48am UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/18 "2022-05-17T06:48:48Z")

</div>

@Nimra_Fatima can you share the full file please?

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [May 17, 2022, 3:31pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/19 "2022-05-17T15:31:21Z")

</div>

That looks like it should work, but as @cocreature implied, it may depend on the rest of the file, particularly the overall indentation.

---

<div class="post-metadata">

**Author:** ![Nimra\_Fatima](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/nimra_fatima/32/3961_2.png) [@Nimra\_Fatima](https://forum.canton.network/u/Nimra_Fatima)\
**Post date:** [May 17, 2022, 7:20pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/20 "2022-05-17T19:20:32Z")

</div>

@cocreature here is the code

module UserAdmin where

import Token  
import Payment

template Issuer  
with  
userAdmin: Party  
issuer: Party  
where  
signatory userAdmin  
ensure userAdmin /= issuer

```
  nonconsuming choice MintToken: ContractId Token 
    with 
      description: Text 
      initialPrice: Decimal 
      currency: Text 
      royaltyRate: Decimal 
      thumbnail: Thumbnail
        
    controller issuer 
    do 
      issued <- getTime
      create Token
        with 
          lastPrice = initialPrice
          owner = issuer
          ..

controller userAdmin can 
  RevokeIssuer: () 
    do return ()

```

template IssuerRequest  
with  
userAdmin: Party  
issuer: Party  
reason: Text  
where  
signatory issuer

```
key (userAdmin, issuer): (Party, Party)
maintainer key._2

controller userAdmin can 
  GrantIssuerRights: ContractId Issuer 
    do 
      create Issuer with ..

  RejectIssuerRequest: () 
    do return ()

```

template Owner  
with  
userAdmin: Party  
owner: Party  
where  
signatory userAdmin  
ensure userAdmin /= owner

```
key (userAdmin, owner): (Party, Party)
maintainer key._1

controller owner can 
  nonconsuming AcceptTokenAsNewOwner: (ContractId Token, ContractId Payable, Optional (ContractId Payable))
    with 
      offerId: ContractId TokenOffer 
    do 
      exercise offerId AcceptToken 

  nonconsuming AcceptTokenByKey: (ContractId Token, ContractId Payable, Optional (ContractId Payable))
    with 
      issuer: Party 
      currentOwner: Party 
      description: Text 
    do 
      exerciseByKey @TokenOffer (issuer, currentOwner, description) AcceptToken

controller userAdmin can 
  RevokeOwnerRights: () 
    do return ()

```

template OwnerRequest  
with  
userAdmin: Party  
owner: Party  
reason: Text  
where  
signatory owner

```
key (userAdmin, owner): (Party, Party)
maintainer key._2

controller userAdmin can 
  GrantOwnerRights: ContractId Owner 
    do 
      create Owner with ..

  RejectOwnerRequest: () 
    do return ()
```

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [May 17, 2022, 7:50pm UTC](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077/21 "2022-05-17T19:50:39Z")

</div>

Please post this as a code block by wrapping it in triple backticks

````
```
yourcodehere
```

````

Otherwise the indentation gets messed up which makes it hard to find issues related to that.

[Next page](https://forum.canton.network/t/features-announced-to-be-deprecated-controller-first-choice-syntax-contract-key-uniqueness-anything-else/4077.md?page=2)
