How can I use multiple parameters in a script that runs against Daml-Hub?
- cohen.avrahamOP 1
G-d willing
Hello,
Following my previous discussion, I would like to ask how do I define (and use) multiple parameters from within the--input-file.
I understand that this is a JSON file.
I was told that when it is only 1 parameter, the file will only contain the text value between " char.
But how do I separate different arguments when I need to use more than one? - alex.graham 3
Hi @cohen.avraham,
To have multiple parameters for the
--input-fileyou can create a custom data type which would correspond to the format and data you use for the input file.For example:
module MyScript where import Daml.Script data ScriptSettings = ScriptSettings with userParty : Party userName : Text userEmail : Text deriving (Show, Eq) runScript : ScriptSettings -> Script () runScript ScriptSettings{..} = do debug $ "The username is " <> userName return ()Then the
--input-fileJSON might look something like:{ "userParty": "ledger-party-kj2340xfkjsdf0923j", "userName": "Alice" "userEmail": "alice@company.com" } - cohen.avraham 2
Thank you very much, it works.