Need help implementing install_code() canister method

I’m trying to implement the installCode_ method below. The canister actor that I’m trying to install the wasmModule to is constructed like so:

shared(msg) actor class Journal (principal : Principal) = this {

I’m pretty sure the issue with the implementation is with the way I’m defining the arg variable.

private func installCode_ (arg: Blob, wasmModule: Blob, canister_id: Principal) : async () {
        await ic.stop_canister({canister_id = canister_id});
        await ic.install_code({
            arg = arg;
            wasm_module = wasmModule;
            mode = #upgrade;
            canister_id = canister_id;
        await ic.start_canister({canister_id = canister_id});

here is how I’m defining the arg varibale that I pass into the installCode_() method:
let arg = Principal.toBlob(principal);

the method is trapping at the ic.install_code() method.
How do I properly define the arg argument that is passed into the

The arg should probably be encoded to Candid. Try to encode the arg with to_candid.

Been a while since I did not write any Motoko but, I did that few months ago in this sample repo: motoko_to_rust_migration/ at 1d51608bbea4f7257d6ed0916a5238d4427ec13b · peterpeterparker/motoko_to_rust_migration · GitHub

private let user: {user: Text} = {user = "David"};
await ic.install_code({
          arg = to_candid(user);
          wasm_module = wasmModule;
          mode = #upgrade;
          canister_id = cId;

this did the trick. thanks again!

1 Like

coolio, happy to hear that!