Skip to content
caffeinelabsPublic

About

IC Management Canister interface for Motoko

Resources

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

 

History

54 Commits

Folders and files

Repository files navigation

IC management canister interface

mops documentation

Motoko interface for the IC management canister (aaaaa-aa). The Motoko types are generated from the upstream Candid spec mirrored at did/ic.did (from dfinity/developer-docs).

See Call module documentation for automatic calculation of the minimum amount of cycles and attaching them to the call.

Examples

Import

import { ic } "mo:ic";
import IC "mo:ic/Types";

ic is the management canister actor; IC is the module of request/response types.

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 } "mo:ic";
import IC "mo:ic/Types";

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

About

IC Management Canister interface for Motoko

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages