# Input file for Script

**URL:** <https://forum.canton.network/t/input-file-for-script/6061>\
**Category:** App Development\
**Tags:** daml, json-api, ledger-api\
**Created:** [February 2, 2023, 8:53am UTC](https://forum.canton.network/t/input-file-for-script/6061 "2023-02-02T08:53:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![star123good](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/star123good/32/1418_2.png) [@star123good](https://forum.canton.network/u/star123good)\
**Post date:** [February 2, 2023, 8:53am UTC](https://forum.canton.network/t/input-file-for-script/6061/1 "2023-02-02T08:53:49Z")

</div>

I’ve a script like the follwing

upgradeInven : Party → [InvenKey] → [Int] → Script ()

And, I hope to run this script

`daml script --dar $(dar_path) --script-name Scripts.InitializeScript:upgradeInven --ledger-host $(ledger_host) --ledger-port $(ledger_port) --input-file exclude-keys.json`

How can I build `exclude-keys.json` to run the script?

---

<div class="post-metadata">

**Author:** ![Mate\_Varga](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mate_varga/32/2308_2.png) [@Mate\_Varga](https://forum.canton.network/u/Mate_Varga)\
**Post date:** [February 2, 2023, 9:03am UTC](https://forum.canton.network/t/input-file-for-script/6061/2 "2023-02-02T09:03:48Z")

</div>

Hi @star123good,

Please note this section from our [documentation](https://docs.daml.com/daml-script/index.html#run-a-script):

> If the `--input-file` flag is specified, the `--script-name` flag must point to a function of one argument returning a `Script` , and the function will be called with the result of parsing the input file as its argument. For example, we can initialize our ledger using the `initialize` function defined above.

So to be able to use the `--input-file` option, first you need to define a data type that encapsulates all your arguments. The easiest way to generate the json is to do it from another daml script which populates and returns an instance of that same data type, using the` --output-file` option.

---

<div class="post-metadata">

**Author:** ![star123good](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/star123good/32/1418_2.png) [@star123good](https://forum.canton.network/u/star123good)\
**Post date:** [February 2, 2023, 9:45am UTC](https://forum.canton.network/t/input-file-for-script/6061/3 "2023-02-02T09:45:10Z")

</div>

Hi, @Mate_Varga

data UpgradeData = UpgradeData with  
operator : Party  
invenkeys : [InvenKey]  
nums: [Int]

upgradeInven : UpgradeData→ Script ()

And, in exclude-keys.json  
{  
“operator”: “Operator”,  
“invenkeys”: ,  
“nums”:   
}

Is this correct?

---

<div class="post-metadata">

**Author:** ![Mate\_Varga](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mate_varga/32/2308_2.png) [@Mate\_Varga](https://forum.canton.network/u/Mate_Varga)\
**Post date:** [February 2, 2023, 1:11pm UTC](https://forum.canton.network/t/input-file-for-script/6061/4 "2023-02-02T13:11:39Z")

</div>

Hi @star123good,

I recommend you run a script just to produce an example, but basically yes.  
I have mocked up your type and ran it to produce an output:

```haskell
data InvenKey = InvenKey with
  keyAttr : Text

data UpgradeData = UpgradeData with
  operator : Party
  invenkeys : [InvenKey]
  nums: [Int]

outputData : Script UpgradeData
outputData = do
  let ik0 = (InvenKey "key0attr")
  let ik1 = (InvenKey "key1attr")
  party <- allocateParty "Party"
  pure ( UpgradeData party [ik0,ik1] [0,1,2] )

```

The output produced when I ran this script with the `--output-file` option:

```haskell
{
  "operator": "party-575096f2-7863-4a38-88d4-441642e61d23::1220c7f8a6da7b70b9daefea37d4d52b7114e5cedeb6df10e76467820af8410f9a9b",
  "invenkeys": [{
    "keyAttr": "key0attr"
  }, {
    "keyAttr": "key1attr"
  }],
  "nums": [0, 1, 2]
}

```
