Multiple Scripts in single file

list_test = script do

I observed we can have multiple such scripts in a single daml file, for each Script result option is also visible on VS.

Want to understand, is this an ideal scenario having more than 1 script in single file?

You can have any number of scripts in any Daml module.

Having multiple Script values in a single file is akin to having multiple unit tests in a single file in other languages.

You have to mentally separate the Script values meant for unit testing from the Script values meant to run against a “live” ledger through daml script. Within the language, there is no reason for them to have a different type, but generally speaking you would write them differently.

Note that while the IDE executes all Script values, the daml script command only executes the one mentioned in the CLI invocation. Also note that daml script can run a -> Script b values, which are not run by the IDE (via the --input-file flag).

1 Like