const agent = await createAgent();
const managementCanister = ICManagementCanister.create({ agent });
if (host === "https://ic0.app") {
try {
const walletCanisterId = Principal.fromText(
process.env.WALLET_CANISTER_ID
);
console.log("Checking wallet canister:", walletCanisterId.toText());
const statuss = await managementCanister.canisterStatus(
walletCanisterId
);
console.log("Wallet canister verified successfully", statuss);
} catch (walletError) {
console.error("Wallet canister verification failed:", walletError);
throw new Error(
"Wallet canister not found or not accessible. Check your WALLET_CANISTER_ID and credentials."
);
}
}
let newFrontendCanisterId;
if (host.includes("localhost") || host.includes("127.0.0.1")) {
const canister_id =
await managementCanister.provisionalCreateCanisterWithCycles({
settings: {
controllers: [(await agent.getPrincipal()).toText()],
freezing_threshold: [],
memory_allocation: [],
compute_allocation: [],
},
amount: [],
});
newFrontendCanisterId = canister_id;
} else {
const canister_id = await managementCanister.createCanister({
settings: {
controllers: [(await agent.getPrincipal()).toText()],
},
});
newFrontendCanisterId = canister_id;
}
i’m getting this error when trying to create the canister on icp network though it was working fine on localhost
Error creating canister: AgentHTTPResponseError [AgentError]: Server returned an error:
Code: 400 (Bad Request)
Body: error: canister_not_found
details: The specified canister does not exist.
at HttpAgent._HttpAgent_requestAndRetry (/Users/mac/Documents/Learning/Misc/ManagementCanister/n
at HttpAgent._HttpAgent_requestAndRetry .... {
response: {
ok: false,
status: 400,
statusText: 'Bad Request',
headers: [
[Array], [Array],
[Array], [Array],
[Array], [Array],
[Array], [Array],
[Array]
]
}
}
any clue on why i could be getting this error ? i used provisionalCreateCanisterWithCycles
for local replica and it worked but it doesn’t seems to work on the ic network https://ic0.app