INNER CODE UNIT · JavaScript
getActor
dfinity/examples · motoko/vetkeys/basic_vetkd/frontend/src/main.js:24
async function getActor() {
if (backendActor) return backendActor;
const canisterId = canisterEnv?.["PUBLIC_CANISTER_ID:backend"];
if (!canisterId) throw new Error("Canister ID for backend is not set. Deploy first.");
const agent = await HttpAgent.create({
identity: authClient ? await authClient.getIdentity() : undefined,
rootKey: canisterEnv?.IC_ROOT_KEY,
});
backendActor = createActor(canisterId, { agent });
return backendActor;
}
function setStatus(id, msg) {
const el = document.getElementById(id);
if (el) el.textContent = msg;
}
function getInputValue(id) {