Skip to content
CCPEDIAby Unity Nodes
App Development

How can I use multiple parameters in a script that runs against Daml-Hub?

3 posts311 views6 likesLast activity May 2022

  1. 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?

  2. alex.graham 3

    Hi @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"
    }
    
  3. cohen.avraham 2

    Thank you very much, it works.