Running a pure script without a ledger?
- LucianoOP
Related to posts
Hi looking at (1) it seems to be common knowledge how to access test data from a Script. But I am failing to figure out how to do that from reading the documentation and this forum. According to the DAML Script docu (2), the --input-file option serves that purpose. But unless I have been overlooking this repeatedly, it is not clear how the script can access that information. And looking at the docu for the Daml.Script library (3) there seems to be no function that can access that information. …
Thanks Moritz for your prompt response. It’s fairly confusing. So running a “daml test” runs all scripts in the project or given DAR file and runs them in a special in-memory emulator? “daml test-script” takes a DAR file, a script identifier and a ledger connection and runs a script against the ledger? “daml script” runs the script on a special in-memory ledger emulator? When wishing to simply open a DAML file with a script in the IDE it means that you start a sandbox and run all scripts in…
Is there a way to run a pure script that doesn’t execute any
Commandswithout connecting to a ledger?
For instance, usingdaml scriptbut without the--ledger-hostoption?What I’m trying to achieve here is to run a
scenario : Script Textand output the resulting string.
I could of coursefailthe script and usedebug, but that’s kind of horrible. - Remy
You two concerns are a bit unrelated.
Currently the Daml script command line requires a ledger to connect to. The only way to run a script without a functional ledger is inside Daml Studio.
On the other hand, to get the output of a script, you can use the option
--output-fileto specify a file where the result of the script will be written to in JSON format. - Luciano
Remy:On the other hand, to get the output of a script, you can use the option
--output-fileto specify a file where the result of the script will be written to in JSON format.Yes, I got this bit - I think it’s mentioned in one of the linked posts.
What I don’t want is to have to do is
daml startto spin up a ledger every time i rundaml script, because I’m not actually reading/writing any contracts. I’m just evaluating a pure function.
Remy:Currently the Daml script command line requires a ledger to connect to. The only way to run a script without a functional ledger is inside Daml Studio.
Yes, it would have been nice to have this functionality in
daml script, so that if I omit--ledger-host, it just uses the secnario-service. - cocreature
For now, there is no option for this in
daml scriptbut you can usedaml replto evaluate your script which does not require a ledger. Note that it doesn’t use the scenario service either, it will just fail for ledger operations but if I understand you correctly that’s fine for your usecase.