Skip to main content

Runtime

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

Import

mo:core/Runtime

Status

  • Runtime module

Public API

Functions

moduleHash() : Blob

Returns the current Sector9 module hash. Use it in contracts that need code identity, especially token identity and module-authorized minting.

Use when: a value or invariant must be tied to the code module that produced it.

selfId() : Principal

Returns the current actor principal.

Use when: contracts or runtime logic need the canister's own principal.

callerId() : Principal

Returns the immediate caller principal.

Use when: runtime access checks or postconditions depend on the caller principal.

callerActorHash() : Blob

Returns the hash associated with the caller actor.

Use when: cross-module checks need code identity instead of only a principal.

callingModuleId() : ?Blob

Returns the local calling module hash when one is available, otherwise null.

Use when: enforcing module-level authority such as verified token minting.

uniqueId() : Blob

Returns a fresh runtime-generated blob.

Use when: code needs an opaque unique value from the runtime.

trap(errorMessage : Text) : None

Terminates execution through the runtime trap path.

Contract

ensures false;

Use when: the current path must abort rather than return a normal value.

unreachable() : None

Terminates execution through the runtime trap path.

Contract

ensures false;

Use when: the current path must abort rather than return a normal value.

Summary