[dfx] How to call a canister as the identity's wallet canister Principal

Hello

When creating and deploying a canister; the deployer is the wallet’s canister of the default identity.

But when I do

dfx --identity id_alice canister call icpTopuper setCanisters "(vec { principal \"$(dfx canister id exampleCanister1)\"; principal \"$(dfx canister id exampleCanister2)\"; principal \"$(dfx canister id exampleCanister3)\"; principal \"$(dfx canister id exampleCanisterBad)\";  })"

It says unauthorized as the call is received default Principal (and not the default's wallet Principal)

I tried to do a delegate call but it seems I need to pass the serialized vec… Any idea on how to achieve this?

cf. wallet_call

  // Call Forwarding
  wallet_call: (record {
    canister: principal; // $(dfx canister id icpTopuper)
    method_name: text; // `setCanisters`
    args: blob; // `"(vec { principal \"$(dfx canister id exampleCanister1)\"; principal \"$(dfx canister id exampleCanister2)\"; principal \"$(dfx canister id exampleCanister3)\"; principal \"$(dfx canister id exampleCanisterBad)\";  })"`
    cycles: nat64; // 0
  }) -> (record { return: blob });

Thank you

@dpdp you can use didc to get a blob encoding
The sytax would be something like this

didc encode "(vec { principal \"$(dfx canister id hello)\"; })" -f blob
DIDL\01mh\01\00\01\01\0a\00\00\00\00\00\00\00\01\01\01

and then you’d do

dfx canister call $(dfx identity get-wallet) wallet_call \
      "(record { canister = principal \"$(dfx canister id icpTopuper)\"; method_name = \"setCanisters\"; args = blob \"DIDL\01mh\01\00\01\01\0a\00\00\00\00\00\00\00\01\01\01\"; cycles = (0:nat64)})"
3 Likes

This is the only way to call a canister as the identity’s wallet canister Principal? Seems… complicated :woozy_face:. It seems like a rather essential thing to do easily, now that the deployer of a canister is the wallet canister of the default identity.

From the 0.6.26 release notes:

Only the default wallet canister principal can perform canister management tasks

The introduction of the cycles wallet canister changes the default principal used to perform key canister management tasks, such as registering a new canister identifier and deploying a new canister on the Internet Computer. This change introduces some inconsistencies in the identity used to perform certain tasks and can result in potential access control issues.

You should note that none of the tutorials have been updated to reflect this specific change in behavior yet and the current version of the Add access control with identities tutorial is known to be invalid for this release. If you want to experiment with access control using the Add access control with identities tutorial, you should install the DFINITY Canister SDK version 0.6.23 (or older).

It would be nice if the release notes gave a hint at what to do, rather than just advise you to downgrade to 0.6.23.

1 Like

This is the only way to call a canister as the identity’s wallet canister Principal?

This is the only way as of the 0.6.26 hotfix release. The next release (:crossed_fingers:for internal release on Tuesday) will have better support for call proxy though wallet.

1 Like

Any updates on a hopefully easier way to forward a call through a wallet canister?