Running daml script outside quickstart gives an error
- Nishant_BansalOP 1
~/Downloads » daml script --dar quickstart/.daml/dist/quickstart-0.0.1.dar --script-name Script:trade --ledger-host localhost --ledger-port 6865 --input-file parties.json --output-file result.json Exception in thread "main" java.lang.IllegalArgumentException: Could not find DAML script ade2af4a6fbcfe22272a2899c6ff1bbbd9eb1427300d7d7bdc0749a0ef1b015f:Script.daml:tradeIn my Downloads folder, I have Script.daml, parties.json, quickstart folder.
My Script.daml looks like this:
module Script where import Daml.Script import Iou import IouTrade data Parties = Parties with alice : Party bob : Party usBank : Party eurBank : Party trade : Parties ->Script (ContractId Iou) trade parties = do -- Banks issue IOU transfers. submit parties.eurBank do createCmd Iou with issuer = parties.eurBank owner = parties.eurBank currency = "EUR" amount = 100.0 observers = [] - cocreature 1
Hi @Nishant_Bansal,
Most of the time you see this type of error if you did not run
daml buildafter making changes to your DAML Script.However, looking at the error message I think there might be something else going on here:
It looks like you might have specified
--script-name Script.daml:tradeinstead of--script-name Script:trade. The argument should be of the formModuleName:IdentifiernotFileName:Identifier. The command you showed looks correct but if you didn’t just copy paste it, maybe the one you used did have this issue? - Nishant_Bansal 1
I have run “daml build” on the quickstart project and trying to run the command from outside the quickstart folder i.e.from Download folder. My quickstart folder doesn’t contain Script.daml.
Script.daml is present in download folder.I have copy paste the above command. It is Script:trade not Script.daml:trade.
- cocreature 1
You need to place
Script.damlin thedamldirectory of the quickstart project. Otherwise,daml buildwill not include it in the resulting DAR. - Nishant_Bansal 1
So is there any way to not to place the Script.daml in daml folder and build the dar without it.
Then later on we can use that script from somewhere outside. - cocreature 1
If you don’t want to include the script in the DAR with with your templates, you need to put it in a separate DAR that depends on
quickstart-0.0.1.darusingdata-dependencies. So create a new project with a separatedaml.yamlwheresourcepoints to a directory containing (only)Script.damlanddata-dependenciesincludes a path toquickstart-0.0.1.dar. - Nishant_Bansal 1
Do i need to upload this new dar on sandbox too?
- cocreature 1
No, you only need to upload DARs containing templates to the ledger. DAML Scripts are run on the client side so the ledger does not need the DAR. The same applies to triggers.