# What is the right way to initialize a canister?

**URL:** <https://forum.dfinity.org/t/what-is-the-right-way-to-initialize-a-canister/21223>\
**Category:** Motoko\
**Created:** [July 6, 2023, 11:31pm UTC](https://forum.dfinity.org/t/what-is-the-right-way-to-initialize-a-canister/21223 "2023-07-06T23:31:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwertytrewq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/qwertytrewq/32/10423_2.png) [@qwertytrewq](https://forum.dfinity.org/u/qwertytrewq)\
**Post date:** [July 6, 2023, 11:31pm UTC](https://forum.dfinity.org/t/what-is-the-right-way-to-initialize-a-canister/21223/1 "2023-07-06T23:31:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [July 7, 2023, 7:19am UTC](https://forum.dfinity.org/t/what-is-the-right-way-to-initialize-a-canister/21223/2 "2023-07-07T07:19:02Z")

</div>

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>`
