Overview
The Canister Plugin supports:- Lifecycle Management: Create, start, stop, delete canisters
- Code Deployment: Install, upgrade, uninstall WASM modules
- Method Calls: Query and update calls with IDL support
- Actor Creation: Direct typed actor creation
- Controller Management: Add/remove controllers, update settings
- Metrics Tracking: Call counts, response times, error rates
Lifecycle Operations
create(options?)
Create a new canister.
Parameters:
options
(optional):ICanisterCreateOptions
settings
:ICanisterSettings
- Initial canister settingscycles
:bigint | string
- Initial cycles amount
Promise<{ canisterId: Principal }>
- Created canister information
Example:
deploy(options)
Deploy WASM code to a canister.
Parameters:
options
:ICanisterDeployOptions
canisterId
:Principal
- Target canister IDwasmModule
:Uint8Array
- WASM module bytesinstallArgs
:Uint8Array
- Installation arguments (optional)mode
:'install' | 'upgrade' | 'reinstall'
- Installation mode (default: ‘install’)
Promise<IDeployResult>
canisterId
:Principal
- Deployed canister IDmoduleHash
:string
- Hash of deployed modulecyclesUsed
:bigint
- Cycles consumed during deployment
start(canisterId)
Start a stopped canister.
Parameters:
canisterId
:Principal | string
- Canister to start
Promise<void>
Example:
stop(canisterId)
Stop a running canister.
Parameters:
canisterId
:Principal | string
- Canister to stop
Promise<void>
Example:
delete(canisterId)
Delete a canister (must be stopped first).
Parameters:
canisterId
:Principal | string
- Canister to delete
Promise<void>
Example:
Method Calls
call(options)
Execute an update call on a canister.
Parameters:
options
:ICanisterCallOptions
canisterId
:Principal
- Target canistermethodName
:string
- Method to callargs
:unknown[]
- Method argumentsidlFactory
:IDL.InterfaceFactory
- Candid interface factory
Promise<unknown>
- Method result
Example:
query(options)
Execute a query call on a canister (read-only, faster).
Parameters:
options
:ICanisterQueryOptions
canisterId
:Principal
- Target canistermethodName
:string
- Method to callargs
:unknown[]
- Method argumentsidlFactory
:IDL.InterfaceFactory
- Candid interface factory
Promise<unknown>
- Method result
Example:
createActor(canisterId, idlFactory)
Create a typed actor for easier method calls.
Parameters:
canisterId
:Principal | string
- Target canisteridlFactory
:IDL.InterfaceFactory
- Candid interface factory
ActorSubclass<T>
- Typed actor instance
Example:
Status and Information
getStatus(canisterId)
Get detailed canister status information.
Parameters:
canisterId
:Principal | string
- Canister to query
Promise<ICanisterStatus>
canisterId
:Principal
- Canister IDstatus
:'running' | 'stopping' | 'stopped'
- Current statussettings
:ICanisterSettings
- Current settingsmemorySize
:bigint
- Memory usage in bytescycles
:bigint
- Current cycles balancemoduleHash
:string
- Hash of installed module
Controller Management
updateSettings(canisterId, settings)
Update canister settings.
Parameters:
canisterId
:Principal | string
- Target canistersettings
:Partial<ICanisterSettings>
- Settings to update
Promise<void>
Example:
addController(canisterId, controller)
Add a new controller to a canister.
Parameters:
canisterId
:Principal | string
- Target canistercontroller
:Principal | string
- New controller principal
Promise<void>
Example:
removeController(canisterId, controller)
Remove a controller from a canister.
Parameters:
canisterId
:Principal | string
- Target canistercontroller
:Principal | string
- Controller to remove
Promise<void>
Example:
Utility Functions
formatCycles(cycles)
Format cycles amount for display.
Parameters:
cycles
:bigint
- Cycles amount
string
- Formatted cycles (e.g., “2.5T”, “1.2B”)
Example:
parseCycles(cycles)
Parse cycles string to bigint.
Parameters:
cycles
:string
- Cycles string (e.g., “2.5T”, “1B”)
bigint
- Parsed cycles amount
Example:
exists(canisterId)
Check if a canister exists.
Parameters:
canisterId
:Principal | string
- Canister to check
Promise<boolean>
- Whether canister exists
Example:
isController(canisterId)
Check if current identity is a controller of the canister.
Parameters:
canisterId
:Principal | string
- Canister to check
Promise<boolean>
- Whether current identity is a controller
Example: