How can I use multiple parameters in a script that runs against Daml-Hub?
App Development3 posts283 views6 likesLast activity May 2022
CO
cohen.avrahamOP
May 2022G-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?
AL
alex.graham
May 2022Hi @cohen.avraham,
To have multiple parameters for the --input-file you 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-file JSON might look something like:
{
"userParty": "ledger-party-kj2340xfkjsdf0923j",
"userName": "Alice"
"userEmail": "alice@company.com"
}
CO
cohen.avraham
May 2022Thank you very much, it works.