Module api

Source
Expand description

System API bindings.

This module provides Rust ergonomic bindings to the system APIs.

Some APIs require more advanced handling and are organized into separate modules:

  • For the inter-canister calls API, see the call module.
  • For the stable memory management API, see the .

APIs that are only available for wasm32 are not included. As a result, system APIs with a numeric postfix (indicating the data bit width) are bound to names without the postfix. For example, ic0::msg_cycles_available128 is bound to msg_cycles_available, while ic0::msg_cycles_available has no binding.

Functions that provide bindings for a single system API method share the same name as the system API. For example, ic0::msg_reject_code is bound to msg_reject_code.

Functions that wrap multiple system API methods are named using the common prefix of the wrapped methods. For example, msg_arg_data wraps both ic0::msg_arg_data_size and ic0::msg_arg_data_copy.

Modules§

callDeprecated
APIs to make and manage calls in the canister.
management_canisterDeprecated
Functions and types for calling the IC management canister.
stableDeprecated
APIs to manage stable memory.

Enums§

CanisterStatusCode
The status of a canister.
PerformanceCounterType
The type of performance counter.
SignCostError
The error type for cost_sign_with_ecdsa and cost_sign_with_schnorr.

Functions§

accept_message
Accepts the message in canister_inspect_message.
call_context_instruction_counter
Returns the number of WebAssembly instructions the canister has executed within the call context of the current Message execution since Call context creation.
callerDeprecated
Returns the caller of the current call.
canister_balanceDeprecated
Gets the amount of funds available in the canister.
canister_balance128Deprecated
Gets the amount of funds available in the canister.
canister_cycle_balance
Gets the current cycle balance of the canister.
canister_liquid_cycle_balance
Gets the current amount of cycles that is available for spending in calls and execution.
canister_self
Gets canister’s own identity.
canister_status
Gets the status of the canister.
canister_version
Gets the canister version.
certified_data_set
Sets the certified data of this canister.
cost_call
Gets the amount of cycles that a canister needs to be above the freezing threshold in order to successfully make an inter-canister call.
cost_create_canister
Gets the cycle cost of the Management canister method creating_canister.
cost_http_request
Gets the cycle cost of the Management canister method http_request.
cost_sign_with_ecdsa
Gets the cycle cost of the Management canister method sign_with_ecdsa.
cost_sign_with_schnorr
Gets the cycle cost of the Management canister method sign_with_schnorr.
cost_vetkd_derive_key
Gets the cycle cost of the Management canister method vetkd_derive_key.
cycles_burn
Burns cycles from the canister.
data_certificate
When called from a query call, returns the data certificate authenticating certified_data set by this canister.
debug_print
Emits textual trace messages.
global_timer_set
Sets global timer.
idDeprecated
Returns the canister id as a blob.
in_replicated_execution
Checks if in replicated execution.
instruction_counter
Returns the number of instructions that the canister executed since the last entry point.
is_controller
Determines if a Principal is a controller of the canister.
msg_arg_data
Gets the message argument data.
msg_caller
Gets the identity of the caller, which may be a canister id or a user id.
msg_cycles_accept
Moves cycles from the call to the canister balance.
msg_cycles_available
Gets the number of cycles transferred by the caller of the current call, still available in this message.
msg_cycles_refunded
Gets the amount of cycles that came back with the response as a refund
msg_deadline
Gets the deadline, in nanoseconds since 1970-01-01, after which the caller might stop waiting for a response.
msg_method_name
Gets the name of the method to be inspected.
msg_reject
Rejects the call with a diagnostic message.
msg_reject_code
Returns the reject code, if the current function is invoked as a reject callback.
msg_reject_msg
Gets the reject message.
msg_reply
Replies to the sender with the data.
performance_counter
Gets the value of specified performance counter.
printDeprecated
Prints the given message.
root_key
Gets the public key (a DER-encoded BLS key) of the root key of this instance of the Internet Computer Protocol.
set_certified_dataDeprecated
Sets the certified data of this canister.
set_global_timerDeprecated
Sets global timer.
stable_grow
Attempts to grow the stable memory by new_pages many pages containing zeroes.
stable_read
Reads data from the stable memory location specified by an offset.
stable_size
Gets the current size of the stable memory (in WebAssembly pages).
stable_write
Writes data to the stable memory location specified by an offset.
subnet_self
Gets the ID of the subnet on which the canister is running.
time
Gets current timestamp, in nanoseconds since the epoch (1970-01-01)
trap
Traps with the given message.