运行 `daml start` 上的 daml 脚本
Running daml script on `daml start`
我有一个只有一个脚本的 daml 文件
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
...
有没有办法在我 运行 daml start
时随时执行脚本?
是的!这在 the documentation for Daml Script 中有具体说明:
You can use Daml script to initialize a ledger on startup. To do so, specify an init-script: ScriptExample:initializeFixed
field in your daml.yaml
. This will automatically be picked up by daml start
and used to initialize sandbox.
在你的情况下,这将是:
init-script: User:makeAdmin
我有一个只有一个脚本的 daml 文件
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
...
有没有办法在我 运行 daml start
时随时执行脚本?
是的!这在 the documentation for Daml Script 中有具体说明:
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.
在你的情况下,这将是:
init-script: User:makeAdmin