How to pass another canister as actor-constructor-argument?

I played a bit with examples from Payment-Channel-Example
There an actor type is expected in constructor of the payment-actor. I have following questions:

  • How to pass a different already existing canister as constructor argument?

    • I tried dfx deploy paymentchannel --argument '("rkp4c-7iaaa-aaaaa-aaaca-cai")' but got the error:
      nvalid data: Unable to serialize Candid values: type mismatch: "rkp4c-7iaaa-aaaaa-aaaca-cai" cannot be of type service { allowance : (Owner, Owner) -> (nat) query; approve : (Owner, nat) -> (bool); balanceOf : (Owner) -> (opt nat) query; name : () -> (text) query; symbol : () -> (text) query; totalSupply : () -> (nat) query; transfer : (Owner, nat) -> (bool); transferFrom : (Owner, Owner, nat) -> (bool); }
  • Is it possible to define a default constructor argument in dfx.json for an motoko actor?


Try (principal "rkp4c-7iaaa-aaaaa-aaaca-cai")

1 Like

It didn’t work with “principal” but with “service”, Thanks!

Here is the working command for others: dfx deploy paymentchannel --argument '(service "rkp4c-7iaaa-aaaaa-aaaca-cai")'