Skip to main content

Cycles

Reference for mo:core/Cycles in the core library.

Cycles operations are trusted system calls. Verification can reason about the contracts you place around the returned amounts, but the runtime accounting itself is outside the verifier.

Import

mo:core/Cycles

Status

  • Runtime module

Public API

Functions

balance() : Nat

Reads the current cycle accounting value from the runtime.

Use when: runtime logic needs the canister's current cycle balance.

available() : Nat

Reads the current cycle accounting value from the runtime.

Use when: an update method needs to inspect how many cycles were attached to the call.

accept<system>(amount : Nat) : Nat

Applies the corresponding cycle operation through the system runtime.

Use when: a method accepts attached cycles and needs the accepted amount returned by the runtime.

refunded() : Nat

Reads the current cycle accounting value from the runtime.

Use when: code needs to inspect cycles refunded from an outgoing call.

burn<system>(amount : Nat) : Nat

Burns cycles through the system runtime and returns the runtime-reported amount.

Use when: code intentionally burns cycles and needs the runtime-reported burned amount.

Summary

  • Runtime module under mo:core/Cycles.
  • Exposes 5 public functions.