Deployment Arguments via dfx.json

It would be wonderful is we we could pass arguments via dfx.json.

Take for instance the following example:

{
  "canisters": {
    "foo_bar_baz": {
      "main": ".....",
      "type": "motoko"
      "args" : {
        "ic" : "(record { prod = true; foo = "bar real" }, 123)",
        "staging" : "(record { prod = false; foo = "bar fake" }, 452)",
        "local" : "(record { prod = true; foo = "bar fake" }, 222)",
      },
    },
  "networks": {
    "staging": {
      "providers": [
        "https://ic0.app"
      ],
      "type": "persistent"
    },
    "local": {
      "bind": "127.0.0.1:8000",
      "type": "ephemeral"
    }
  },
  "version": 1
}
3 Likes

It would be wonderful if we could pass arguments via dfx.json**

Getting errors editing the post…

3 Likes

+1, this would be really helpful!

1 Like

Yes and the ability to reference a .did file as the value for the “args” key

There is the field canisters.<canister name>.args in dfx.json that takes a string with a candid argument inside to use when deploying the canister. Is this sufficient or is it necessary to have network-specific arguments?

Which option do you mean exactly?

  • Accept a file path as part of dfx.json’s canisters.<canister name>.args field or
  • Ability to specify dfx deploy --argument-file?
1 Like