How to assign default values in Daml
- DaveOP 1
I’m trying to work out how to assign a default value in Daml. I came across this stackoverflow answer and can’t understand why I’m getting the error ‘parse error on input ‘0.00’’ under the '0.00. My code:
template ChildInvite with parent : Party child : Party where signatory parent controller child can AcceptInvite : ContractId Child with parent : parent child : child money : 0.00 - cocreature 1
x : yis a type annotation specifying thatxhas typey. So in your example you’re specifying thatmoneyhas type0.0which is an error since0.0is a value of typeDecimalbut not a type itself.More generally
withon a choice specifies the choice argument fields and their types but I believe you don’t actually want any arguments to that choice, you want to create aChild(hello frankenstein) and set the fields to the given values. For that, try something like the following:template ChildInvite with parent : Party child : Party where signatory parent controller child can AcceptInvite : ContractId Child do create Child with parent = parent child = child money = 0.00