Skip to content
CCPEDIAby Unity Nodes
App Development

How do you construct an Enum using the Canton command line?

2 posts336 views1 likesLast activity Jan 2023

  1. lashenhurstOP

    Hi all,

    Looking to write up a bootstrap script for our testing canton environment, and one of the contracts I’d like the script to create contains an Enum, unfortunately I’m not currently able to get the command formatted in the right way. Here’s what I tried:

    val pkgData = sandbox.packages.find("Main.Data").head
    val enumId = Map("packageId" -> pkgData.packageId, "moduleName" -> "Main.Data", "entityName" -> "MyEnum")
    val enum = Map("enumId" -> enumId, "constructor" -> "VALUE")
    

    But then when I create the command providing that in the args, I get “unknown record” error for that enum.

    Any help would be greatly appreciated!

  2. Mate_Varga 1

    Hi @lashenhurst,

    I believe you do not have to create the enumId, could you please try to use the following?

    import com.daml.ledger.api.v1.value.Value
    import com.daml.ledger.api.v1.value.Enum
    val enum = Value.Sum.Enum(Enum(constructor="VALUE"))