moxzi
Docs / Reference / moxzi CLI reference

moxzi CLI referencealpha

Every moxzi command and option.

moxzi COMMAND --help prints the same information.

Commands#

CommandDoes
build ENTRYCompile and link a Motoko program
link INPUTLink an unlinked module
deps ENTRYList the files a build reads
stable-compatible PREVIOUS NEWCheck an upgrade between two stable signatures (.most files)
candid-compatible PREVIOUS NEWCheck that a new Candid interface can replace an old one for existing callers
agent-bindings DIDGenerate a typed Motoko client for a canister, for ic-agent
verifyCheck an on-chain build's record
publish WASMPublish a wasm to an ICRC-118 registry
deprecateMark a published version as deprecated
host new PLATFORM DIRCreate an actor platform project. Also host list, host examples, host principal
kernel add PACKAGEOpt your application into an installed package's native kernel
kernel build CRATEBuild a Rust crate into a native kernel (a .kernel.toml file)
kernel verify TARGETRebuild a kernel from its source and compare it with its pins
kernel sdk DIRWrite the moxzi-kernel SDK, for cargo generate-lockfile and your editor
infoShow the compiler and linker in use, with their hashes
cache path, cache clearShow or empty the compiled-compiler cache

Options for every command#

OptionEffect
--compiler WASMUse this compiler instead of the one found automatically
--timingsPrint how long each phase took
--pem FILESign Internet Computer calls with this key (Ed25519, secp256k1 or P-256 PEM)
--identity-dfx NAME, --identity-icp NAMESign with this dfx or icp identity's PEM file

build#

OptionEffect
-o, --out WASMOutput file. Default: the entry name with .wasm
--no-idlDon't write the .did file
--gzipAlso write WASM.gz
--debugKeep debug { } blocks
--no-linkWrite an unlinked module
--linker WASMUse this linker
--package NAME PATHMap mo:NAME to PATH. Repeatable
--root DIRThe project directory, seen by the compiler as /src
-v, --verbosePrint the compiler's debug output
-A, -W, -E CODESAllow, enable, or make an error of warning codes. Comma-separated; repeatable
--implicit-derivation-depth NMaximum depth of implicit argument derivation. Default 100

Upgrades and metadata#

OptionEffect
--stable-typesAlso write the stable signature, as a .most file with the same name as the wasm
--enhanced-migration DIRUse the migration modules in DIR
--stable-baseline MOSTCheck the migration chain against the deployed signature
--enhanced-orthogonal-persistenceAllow upgrading a canister that still uses classical persistence. The migration can't be undone. Without this option, such an upgrade fails and the canister keeps running its old code
--public-metadata NAMEMake a metadata section public. Repeatable. Replaces the default (candid:service, candid:args)
--omit-metadata NAMELeave a metadata section out. Repeatable

Metadata names: candid:service, candid:args, motoko:stable-types, motoko:compiler.

Runtime options#

OptionEffect
--compact-rtsLink a runtime system with a smaller heap, for moxzid and moxzi-web
--ephemeralSkip per-message rollback snapshots: faster, but a trap doesn't roll back and state isn't kept across restarts
--actor-max-pages NCap the memory of actors created from actor classes, in 64 KiB pages
--top-max-pages NCap the top-level actor's memory, in 64 KiB pages
--actor-stack-kib KIBStack size for compiled actors. Default 4096. Must be a multiple of 64
--stable-regions, --max-stable-pages N, --stabilization-instruction-limit N, --measure-rts-stackAs in moc
--no-index-fast-pathTurn off the checked array-index optimisation
--candid-fast-pathSkip decoding a Candid type table that matches the one this compiler emits
--wasm-tail-callEmit tail calls for await* chains

Build performance#

OptionEffect
--stack-budget NHow often the compiler pauses. Higher is faster for large projects. Doesn't change the output
--force-gcCollect garbage in the compiler after every step. Doesn't change the output
--progress NPrint progress every N steps
--status-secs SAlso print the current compiler phase, at most every S seconds
--max-steps NGive up after N steps. Default 5,000,000

Native kernels#

OptionEffect
--accept-kernel PACKAGE=sha256:HEXAccept a third-party native kernel, by the exact bytes your [kernels] pins. Repeatable. Recorded for your user, so later builds of the same bytes don't ask; a new version asks again

A native kernel is compiled code that runs inside your canister and shares its memory: it can read and write anything in the canister's heap, and its pin guarantees which bytes run, not that they're correct or benign. The first build that links a kernel moxzi doesn't build and pin itself shows its package, sha256, source and commit, then stops until you accept it. In a terminal, type yes; in CI and scripts, pass --accept-kernel. --yes doesn't accept kernels. Set MOXZI_KERNEL_ACKS to keep the acceptances in another file. See Native kernels.

On-chain builds#

OptionEffect
--remote URLBuild on a compiler canister, through this IC gateway
--canister IDThe compiler canister. Required with --remote
--resume-job IDContinue an existing job instead of starting a new one
--yesDon't ask before paying. Doesn't accept third-party kernels
--link-locallyWith native kernels: if the compiler canister can't link the build, link it on this machine. The result then has no linked-hash attestation from the canister

Experimental#

OptionEffect
--experimental-local-actors NEnable actor*, with N slots
--experimental-local-actor-persistenceIgnored, with a warning. actor* instances are kept across upgrades by default; declare one transient actor* to opt out
--local-continuations NPending continuation slots for actor*
--experimental-private-gc, --private-gc-bounce-every NCollect garbage inside a message at await* points
OptionEffect
-o, --out WASMOutput file. Default: INPUT.linked.wasm
--linker WASMUse this linker
--compact-rtsLink the compact runtime system
-v, --verbosePrint the linker's debug output

deps#

OptionEffect
--package NAME PATH, --root DIRAs for build
--paths-onlyPrint only the compiler's paths, one per line

verify#

OptionEffect
--remote URL, --canister IDThe compiler canister. Required
--job NThe build to check. Default: the most recent
--listList recent builds instead
--entry FILECompare recorded source hashes with your files
--artifact WASMCompare a wasm's hash with the recorded artifact
--expect-module WASMCheck that the canister runs this module

publish#

OptionEffect
--remote URL, --registry IDThe registry. Required
--namespace NAME, --version X.Y.ZWhere to publish. Required
--canister ID, --job NAttach this build record
--previous X.Y.ZThe version this one upgrades
--repo URL, --commit HASHSource location. Read from git when possible
--description TEXTWhat this version is
--create, --name NAMECreate the namespace first
--allow-offchainAllow publishing a --compact-rts build
--dry-runShow what would be sent, and send nothing

deprecate#

OptionEffect
--remote URL, --registry ID, --namespace NAME, --version X.Y.ZThe version. Required
--reason TEXTWhy
--undoRemove the deprecation

agent-bindings#

OptionEffect
--name NAMEModule name. Default: the file name
-o, --out FILEOutput file. Default: standard output
--agent-import PATHImport path for the agent. Default mo:ic-agent

host new#

OptionEffect
--example NAMEcounter (default), ledger or saga

kernel add#

moxzi kernel add PACKAGE opts your application into the native kernel of a package it already depends on. It shows the kernel's package, version, sha256, size, functions, and declared source and commit, checks that the kernel file's bytes match its own sha256, then writes the pin into your mops.toml:

[kernels]
moxzi-hash = "sha256:..."

Only that line changes. If there is no [kernels] table, moxzi appends one, and the rest of the file keeps its formatting. Running it again after the package changes updates the pin. A package without a kernel is refused.

For a third-party kernel (one moxzi doesn't build and pin itself), add also prints what a kernel can do. Adding the pin is not the same as accepting the kernel: the first build that links it still asks you to accept those bytes.

OptionEffect
--root DIRThe application directory. Default: the current directory

kernel build#

moxzi kernel build CRATE compiles a Rust crate into a native kernel and writes a .kernel.toml file: the wasm in base64, its sha256 and its size. The same crate gives the same bytes on every machine, so anyone can rebuild a kernel and check its pin. Writing a kernel walks through a complete one.

OptionEffect
-o, --out FILEOutput file. Default: NAME.kernel.toml in the current directory, where NAME is the crate's package name without a -kernel suffix

You need rustup with the toolchain nightly-2026-07-25 and its rust-src component. Install them with rustup toolchain install nightly-2026-07-25 --profile minimal --component rust-src. moxzi checks the compiler and its linker by commit. If either is missing or different, the build stops and prints the rustup command that fixes it.

The crate must follow these rules:

RuleWhy
crate-type = ["staticlib"], #![no_std]A kernel is linked into the canister as a position-independent wasm64 library
A Cargo.lock next to Cargo.tomlThe build uses --locked, so the lock decides every dependency version. Commit it
The SDK as moxzi-kernel = { path = "../moxzi-kernel" } (or "../../moxzi-kernel", and so on)moxzi builds against the SDK it carries, at the same path on every machine. What is at ../moxzi-kernel on your disk is not used
Other path dependencies inside the crate directoryOnly the crate directory is copied into the build
Exports in src/lib.rs, as #[no_mangle] pub extern "C" fn or pub unsafe extern "C" fnEvery such function in that file is exported
Build configuration in [package.metadata.moxzi-kernel] cfg = ['name="value"']The only way to pass --cfg values to dependencies

Every build runs in /tmp/moxzi-kernel-build, which is deleted first. One build runs at a time. RUSTFLAGS, RUSTC_WRAPPER and the other cargo and rustc settings in your environment are ignored, and each one is named in the output. Cargo configuration files still apply, and each one found is named too.

Write the SDK next to a new crate and generate its lock:

moxzi kernel sdk moxzi-kernel
cargo +nightly-2026-07-25 generate-lockfile --manifest-path reverse-kernel/Cargo.toml
moxzi-kernel: the moxzi-kernel SDK (sources sha256:e055dee34c8e2dd6662fe25e7cb7b7113b648a127122d25a0197d26cc1da3529)
     Locking 1 package to latest compatible version

Build the kernel:

moxzi kernel build reverse-kernel
reverse.kernel.toml: 5633 B, sha256:a0c5237421a2b950e2085d580f53f57dc587db119e4726ecc6f41c5bc40b8e72

kernel verify#

moxzi kernel verify TARGET rebuilds a kernel and compares its bytes with every pin it must equal. It prints MATCH or DIFF for each pin and exits with a non-zero status unless all match. TARGET is one of:

TargetCompared with
A kernel package (a directory whose mops.toml has [kernel])The sha256 of its [kernel] file
A .kernel.toml fileIts sha256. If a package names the file, as for a package
An application (a directory whose mops.toml has [kernels])For each pinned package: the package's file and your [kernels] pin
OptionEffect
--crate DIRRebuild from this crate instead of the package's declared source
--gitClone the declared source even when a local checkout of it is found

Without --crate, moxzi rebuilds from the package's [kernel] source and commit:

sourceRebuilt from
https://HOST/OWNER/REPO/tree/REV/PATHThe directory PATH of the repository, at commit, or at REV when there is no commit
Any other git URLThe repository's root directory, at commit

When the package sits in a git checkout of that repository, moxzi uses the checkout, including uncommitted changes, and says so. Otherwise it fetches the commit into a temporary directory. Declare commit in a published package. A branch name moves, and moxzi prints a note when it checks one.

moxzi kernel verify reverse.kernel.toml --crate reverse-kernel
  MATCH reverse.kernel.toml: sha256:a0c5237421a2b950e2085d580f53f57dc587db119e4726ecc6f41c5bc40b8e72
  MATCH reverse: rebuilt sha256:a0c5237421a2b950e2085d580f53f57dc587db119e4726ecc6f41c5bc40b8e72 (5633 B)
kernel verify: every pin MATCHES the rebuilt bytes

kernel sdk#

moxzi kernel sdk DIR writes the moxzi-kernel SDK that this moxzi builds with. Cargo needs it on disk to generate Cargo.lock, and your editor needs it to check the crate.

OptionEffect
--forceOverwrite DIR when it holds something other than this SDK

Environment variables#

VariableMeaning
MOXZI_COMPILER, MOXZI_LINKERCompiler and linker to use. The options override them
MOXZI_MOPSPath to mops, if it isn't on your PATH
MOXZI_IDENTITYWhere moxzi keeps its own signing key
MOXZI_ADAPTERSWhere host new finds adapters, if not next to moxzi
MOXZI_KERNEL_WORKDIRWhere kernel build builds, instead of /tmp/moxzi-kernel-build. Kernels built anywhere else don't match their pins

Removed options#

--legacy-actors, --no-eop and --trap-on-call-error are no longer supported and print an error. --default-persistent-actors is ignored with a warning: every actor is persistent.

On this pageCommandsOptions for every commandbuildUpgrades and metadataRuntime optionsBuild performanceNative kernelsOn-chain buildsExperimentallinkdepsverifypublishdeprecateagent-bindingshost newkernel addkernel buildkernel verifykernel sdkEnvironment variablesRemoved options