let args = CreateCanisterArgument {
settings: Some(CanisterSettings {
controllers: Some(vec![Principal::from_text("bkyz2-fmaaa-aaaaa-qaaaq-cai").unwrap()]),
compute_allocation: None,
memory_allocation: None,
freezing_threshold: None,
reserved_cycles_limit: None,
log_visibility: None,
wasm_memory_limit: None,
}),
};
ic_cdk::println!("args {:?} ",args);
let (canister_id,): (Principal,) = ic_cdk::api::call::call_with_payment(
Principal::management_canister(),
"create_canister",
(&args,), // Note the tuple here
100_000_000_000, // Adjust this cycle amount as needed
).await.map_err(|(code, msg)| (code, format!("Failed to create canister: {}", msg)))?;
Below error is coming
(variant {Err=record {variant {CanisterError}; “Failed to create canister: failed to decode canister response as (ic_principal::Principal,): Fail to decode argument 0 from table0 to principal”}})
means that your init arguments don’t have the correct type/structure. If you post the full error I may be able to spot the difference, but I am guessing that the enum may be the problem