I have a daml file with just one script
module User where
import Daml.Script
makeAdmin =
script do
admin <- allocateParty "Admin"
submit admin do
createCmd User with username = admin
template User with
username: Party
where
signatory username
key username: Party
maintainer key
...
Is there a way to execute the script any time I run daml start
?
Yes! This is explained in the documentation for Daml Script, specifically:
You can use Daml script to initialize a ledger on startup. To do so, specify an
init-script: ScriptExample:initializeFixed
field in yourdaml.yaml
. This will automatically be picked up bydaml start
and used to initialize sandbox.
In your case, that would be:
init-script: User:makeAdmin