ic-management-js
A library for interfacing with Internet Computer (IC) management canister.

Table of contents
Installation
You can use ic-management-js
by installing it in your project.
npm i @dfinity/ic-management
The bundle needs peer dependencies, be sure that following resources are available in your project as well.
npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils
Usage
The features are available through the class ICMgmtCanister
. It has to be instantiated with a canister ID.
e.g. fetching a token metadata.
import { ICManagementCanister } from "@dfinity/ic-management";
import { createAgent } from "@dfinity/utils";
const agent = await createAgent({
identity,
host: HOST,
});
const { canisterStatus } = ICManagementCanister.create({
agent,
});
const { status, memory_size, ...rest } = await canisterStatus(YOUR_CANISTER_ID);
Features
ic-management-js
implements following features:
:factory: ICManagementCanister
Methods
:gear: create
Method | Type |
---|
create | (options: ICManagementCanisterOptions) => ICManagementCanister |
:gear: createCanister
Create a new canister
Method | Type |
---|
createCanister | ({ settings, senderCanisterVerion, }?: CreateCanisterParams) => Promise<Principal> |
:gear: updateSettings
Update canister settings
Method | Type |
---|
updateSettings | ({ canisterId, senderCanisterVerion, settings, }: UpdateSettingsParams) => Promise<void> |
:gear: installCode
Install code to a canister
Method | Type |
---|
installCode | ({ mode, canisterId, wasmModule, arg, senderCanisterVerion, }: InstallCodeParams) => Promise<void> |
:gear: uninstallCode
Uninstall code from a canister
Method | Type |
---|
uninstallCode | ({ canisterId, senderCanisterVerion, }: UninstallCodeParams) => Promise<void> |
:gear: startCanister
Start a canister
Method | Type |
---|
startCanister | (canisterId: Principal) => Promise<void> |
:gear: stopCanister
Stop a canister
Method | Type |
---|
stopCanister | (canisterId: Principal) => Promise<void> |
:gear: canisterStatus
Get canister details (memory size, status, etc.)
| Method | Type |
| ---------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| canisterStatus
| (canisterId: Principal) => Promise<{ status: { stopped: null; } or { stopping: null; } | { running: null; }; memory_size: bigint; cycles: bigint; settings: definite_canister_settings; idle_cycles_burned_per_day: bigint; module_hash: [] | [...]; }>
|
:gear: canisterInfo
Get canister info (controllers, module hash, changes, etc.)
Method | Type |
---|
canisterInfo | ({ canisterId, numRequestChanges, }: CanisterInfoParams) => Promise<{ controllers: Principal[]; module_hash: [] or [Uint8Array]; recent_changes: change[]; total_num_changes: bigint; }> |
:gear: deleteCanister
Deletes a canister
Method | Type |
---|
deleteCanister | (canisterId: Principal) => Promise<void> |
Resources