What is the right way to initialize a canister?

I have an actor class with arguments.

What is the best way to initialize the canister from this actor class, passing arguments?

  • dfx.json + dfx deploy does not work, because I don’t know any method to pass actor class arguments to dfx deploy
  • Creating an additional argument-less canister only to create from it this canister is too resource wasteful and awkward.
  • I don’t know how to use dfx install (what exactly does it do? can dfx deploy be replaced by it?) and whether it can be a solution.

You should be able to deploy using dfx deploy --argument <init arg>

dfx deploy basically does dfx canister create, followed by dfx build and dfx canister install. There, too, you can use dfx canister install --argument <init arg>

1 Like