Skip to content

Latest commit

 

History

History
49 lines (40 loc) · 1.41 KB

README.md

File metadata and controls

49 lines (40 loc) · 1.41 KB

IC management canister interface

mops documentation

Based on https://github.com/dfinity/interface-spec/blob/master/spec/_attachments/ic.did

Examples

Import

import IC "mo:ic";
let ic = actor("aaaaa-aa") : IC.Service;

or

import {ic} "mo:ic";

Fetch canister status

import {ic} "mo:ic";

let canisterId = Principal.fromText("e3mmv-5qaaa-aaaah-aadma-cai");
let canisterStatus = await ic.canister_status({canister_id = canisterId});

Debug.print("status = " # debug_show canisterStatus.status);
Debug.print("memory_size = " # debug_show canisterStatus.memory_size);
Debug.print("module_hash = " # debug_show canisterStatus.module_hash);
Debug.print("settings = " # debug_show canisterStatus.settings);

Update canister settings

Here we set the canister controllers to a single blackhole canister.

import {ic; CanisterSettings} "mo:ic";

let canisterId = Principal.fromText("e3mmv-5qaaa-aaaah-aadma-cai");
let settings : CanisterSettings = {
	freezing_threshold = null;
	controllers = ?[Principal.fromText("e3mmv-5qaaa-aaaah-aadma-cai")];
	memory_allocation = null;
	compute_allocation = null;
};
await ic.update_settings({
	canister_id = canisterId;
	settings = settings;
});