Expand description
§ic-cdk-management-canister
Functions and types for interacting with the IC management canister.
§Type Definitions
This crate defines the types of arguments and results for the management canister entry points.
Most of these types are re-exported from the ic-management-canister-types crate.
The only exception is that for the argument types that has a sender_canister_version field, this module provides reduced versions instead.
The reduced versions don’t need the sender_canister_version field as it is set automatically in the corresponding functions.
§Call
The majority of the functions in this module are for making calls to the management canister.
§Bounded-wait vs. Unbounded-wait
Interacting with the IC management canister involves making inter-canister calls, which can be either bounded-wait or unbounded-wait. This crate selects the appropriate type of wait call for each method based on the characteristics of the entry point.
The strategy for choosing the type of wait call is as follows:
- Unbounded-wait call by default because the management canister is universally trusted.
- Bounded-wait call (with the default 300s timeout) for methods that only read state.
Please check the documentation of each function for the type of wait call it uses.
If the default behavior is not suitable for a particular use case, the Call struct can be used directly to make the call.
For example, sign_with_ecdsa makes an unbounded-wait call. If a bounded-wait call is preferred, the call can be made as follows:
use ic_cdk_management_canister::{cost_sign_with_ecdsa, SignCallError, SignWithEcdsaArgs, SignWithEcdsaResult};
use ic_cdk::call::Call;
use candid::Principal;
async fn example() -> Result<SignWithEcdsaResult, SignCallError> {
let callee = Principal::management_canister();
let arg = SignWithEcdsaArgs::default();
let cycles = cost_sign_with_ecdsa(&arg)?;
let res: SignWithEcdsaResult = Call::bounded_wait(callee, "sign_with_ecdsa")
.with_arg(&arg)
.with_cycles(cycles)
.await?
.candid()?;
Ok(res)
}§Cycle Cost
Some management canister entry points require cycles to be attached to the call. The functions for calling management canister automatically calculate the required cycles and attach them to the call.
For completeness, this module also provides functions to calculate the cycle cost:
Structs§
- Bip341
- Bip341 variant of Schnorr Aux.
- Canister
IdRecord - Canister ID Record
- Canister
Info Args - Canister Info Args
- Canister
Info Result - Canister Info Result
- Canister
Metadata Args - Canister Metadata Args
- Canister
Metadata Result - Canister Metadata Result
- Canister
Settings - Canister Settings
- Canister
Status Result - Canister Status Result
- Change
- Change
- Chunk
Hash - Chunk hash.
- Code
Deployment Record - Code Deployment Record
- Controllers
Change Record - Controllers Change Record
- Create
Canister Args - Argument type of
create_canisterandcreate_canister_with_extra_cycles. - Creation
Record - Creation Record
- Definite
Canister Settings - Definite Canister Settings
- Delete
Canister Snapshot Args - Delete Canister Snapshot Args.
- Ecdsa
KeyId - ECDSA Key ID.
- Ecdsa
Public KeyArgs - ECDSA Public Key Args.
- Ecdsa
Public KeyResult - ECDSA Public Key Result.
- Environment
Variable - Environment Variable.
- From
Canister Record - From Canister Record
- From
User Record - From User Record
- Http
Header - HTTP Header.
- Http
Request Args - HTTP Request Args
- Http
Request Result - HTTP Request Result
- Install
Chunked Code Args - Argument type of
install_chunked_code. - Install
Code Args - Argument type of
install_code. - Load
Canister Snapshot Args - Argument type of
load_canister_snapshot. - Load
Snapshot Record - Load Snapshot Record
- Memory
Metrics - Memory Metrics
- Node
Metrics - Node Metrics.
- Node
Metrics History Args - Node Metrics History Args.
- Node
Metrics History Record - Node Metrics History Record.
- Provisional
Create Canister With Cycles Args - Argument type of
provisional_create_canister_with_cycles. - Provisional
TopUp Canister Args - Provisional Top Up Canister Args.
- Query
Stats - Query Stats
- Read
Canister Snapshot Data Args - Read Canister Snapshot Data Args.
- Read
Canister Snapshot Data Result - Read Canister Snapshot Data Result.
- Read
Canister Snapshot Metadata Args - Read Canister Snapshot Metadata Args.
- Read
Canister Snapshot Metadata Result - Read Canister Snapshot Metadata Result.
- Schnorr
KeyId - Schnorr Key ID.
- Schnorr
Public KeyArgs - Schnorr Public Key Args.
- Schnorr
Public KeyResult - Schnorr Public Key Result.
- Sign
With Ecdsa Args - Sign With ECDSA Args.
- Sign
With Ecdsa Result - Sign With ECDSA Result.
- Sign
With Schnorr Args - Sign With Schnorr Args.
- Sign
With Schnorr Result - Sign With Schnorr Result.
- Snapshot
- Snapshot.
- Subnet
Info Args - Subnet Info Args.
- Subnet
Info Result - Subnet Info Result.
- Take
Canister Snapshot Args - Take Canister Snapshot Args.
- Transform
Args - Transform Args.
- Transform
Context - Transform Context.
- Transform
Func - Uninstall
Code Args - Argument type of
uninstall_code. - Update
Settings Args - Argument type of
update_settings - Upgrade
Flags - Upgrade Flags
- Upload
Canister Snapshot Data Args - Upload Canister Snapshot Data Args.
- Upload
Canister Snapshot Metadata Args - Upload Canister Snapshot Metadata Args.
- Upload
Canister Snapshot Metadata Result - Upload Canister Snapshot Metadata Result.
- Upload
Chunk Args - Upload Chunk Args
- VetKD
Derive KeyArgs - VetKD derive key request.
- VetKD
Derive KeyResult - VetKD derive key reply.
- VetKD
KeyId - VetKD
Public KeyArgs - VetKD public key request.
- VetKD
Public KeyResult - VetKD public key reply.
Enums§
- Canister
Install Mode - Canister Install Mode
- Canister
Status Type - Canister Status Type
- Canister
Timer - The status of a global timer.
- Change
Details - Change Details
- Change
Origin - Change Origin
- Code
Deployment Mode - Code Deployment Mode
- Ecdsa
Curve - ECDSA Curve.
- Http
Method - HTTP Method.
- LogVisibility
- Log Visibility.
- OnLow
Wasm Memory Hook Status - The status of a low wasm memory hook.
- Schnorr
Algorithm - Schnorr Algorithm.
- Schnorr
Aux - Schnorr Aux.
- Sign
Call Error - The error type for the
sign_with_ecdsaandsign_with_schnorrfunctions. - Snapshot
Data Kind - Snapshot data kind.
- Snapshot
Data Offset - Snapshot data offset.
- Snapshot
Metadata Global - An exported global variable.
- Snapshot
Source - The source of a snapshot.
- VetKD
Curve - The curve used for key derivation.
- Wasm
Memory Persistence - Wasm Memory Persistence
Functions§
- canister_
info - Gets public information about the canister.
- canister_
metadata - Gets canister’s metadata contained in custom sections whose names have the form
icp:public <name>oricp:private <name> - canister_
status - Gets status information about the canister.
- clear_
chunk_ store - Clears the chunk store of a canister.
- cost_
http_ request - Calculates the cost of making an HTTP outcall with the given
HttpRequestArgs. - cost_
sign_ with_ ecdsa - Calculates the cost of ECDSA signanature with the given
SignWithEcdsaArgs. - cost_
sign_ with_ schnorr - Calculates the cost of Schnorr signanature with the given
SignWithSchnorrArgs. - cost_
vetkd_ derive_ key - Calculates the cost of VetKD key derivation with the given
VetKDDeriveKeyArgs. - create_
canister - Creates a new canister.
- create_
canister_ with_ extra_ cycles - Creates a new canister with extra cycles.
- delete_
canister - Deletes a canister.
- delete_
canister_ snapshot - Deletes a specified snapshot that belongs to an existing canister.
- deposit_
cycles - Deposits cycles to a canister.
- ecdsa_
public_ key - Gets a SEC1 encoded ECDSA public key for the given canister using the given derivation path.
- http_
request - Makes an HTTP outcall.
- http_
request_ with_ closure transform-closure - Makes an HTTP outcall and transforms the response using a closure.
- install_
chunked_ code - Installs code into a canister where the code has previously been uploaded in chunks.
- install_
code - Installs code into a canister.
- list_
canister_ snapshots - Lists the snapshots of the canister.
- load_
canister_ snapshot - Loads a snapshot onto the canister.
- node_
metrics_ history - Gets a time series of subnet’s node metrics.
- provisional_
create_ canister_ with_ cycles - Creates a new canister with specified amount of cycles balance.
- provisional_
top_ up_ canister - Adds cycles to a canister.
- raw_
rand - Gets 32 pseudo-random bytes.
- read_
canister_ snapshot_ data - Reads data of a snapshot of a canister.
- read_
canister_ snapshot_ metadata - Reads metadata of a snapshot of a canister.
- schnorr_
public_ key - Gets a SEC1 encoded Schnorr public key for the given canister using the given derivation path.
- sign_
with_ ecdsa - Gets a new ECDSA signature of the given
message_hashwith a user-specified amount of cycles. - sign_
with_ schnorr - Gets a new Schnorr signature of the given message with a user-specified amount of cycles.
- start_
canister - Starts a canister if the canister status was
stoppedorstopping. - stop_
canister - Stops a canister.
- stored_
chunks - Gets the hashes of all chunks stored in the chunk store of a canister.
- subnet_
info - Gets the metadata about a subnet.
- take_
canister_ snapshot - Takes a snapshot of the specified canister.
- transform_
context_ from_ query - Constructs a
TransformContextfrom a query method name and context. - uninstall_
code - Removes a canister’s code and state, making the canister empty again.
- update_
settings - Updates the settings of a canister.
- upload_
canister_ snapshot_ data - Uploads data to a snapshot of that canister.
- upload_
canister_ snapshot_ metadata - Creates a snapshot of that canister by uploading the snapshot’s metadata.
- upload_
chunk - Uploads a chunk to the chunk store of a canister.
- vetkd_
derive_ key - Derives a key from the given input.
- vetkd_
public_ key - Gets a VetKD public key.
Type Aliases§
- Canister
Id - Canister ID.
- Canister
Status Args - Canister Status Args
- Clear
Chunk Store Args - Clear Chunk Store Args
- Create
Canister Result - Create Canister Result
- Delete
Canister Args - Delete Canister Args
- Deposit
Cycles Args - Deposit Cycles Args
- List
Canister Snapshots Args - List Canister Snapshots Args.
- List
Canister Snapshots Result - List Canister Snapshots Result.
- Node
Metrics History Result - Node Metrics History Result.
- Provisional
Create Canister With Cycles Result - Provisional Create Canister With Cycles Result.
- RawRand
Result - Raw Rand Result
- Snapshot
Id - Snapshot ID.
- Start
Canister Args - Start Canister Args
- Stop
Canister Args - Stop Canister Args
- Stored
Chunks Args - Stored Chunks Args
- Stored
Chunks Result - Stored Chunks Result
- Take
Canister Snapshot Result - Take Canister Snapshot Result.
- Upload
Chunk Result - Upload Chunk Result
- Wasm
Module - WASM Module