moxzi
Docs / Actor platforms / wasmCloud

wasmCloudalpha

Run Motoko actors in a wasmCloud host, with state in a wasi:keyvalue bucket.

Each actor runs in a wash-runtime host with a moxzi plugin. Its state is kept in a filesystem-backed wasi:keyvalue bucket, and a timer component fires due timers.

You also need the moxzi SDK and hosts bundles; see Actor platforms.

Prerequisites#

Create and run a project#

moxzi host new wasmcloud hello
cd hello
ONCE=1 ./run.sh
actor.mo -> actor.wasm + actor.did (245563 bytes, 1 file(s), 50 steps, 0.76s)
Counter/1.inc() -> [1]

Run it a second time. The host is a new process, and the actor's state comes back from the platform's store:

ONCE=1 ./run.sh
actor.mo -> actor.wasm + actor.did (245563 bytes, 1 file(s), 50 steps, 0.61s)
Counter/1.inc() -> [2]

ONCE=1 exits after the demo. Without it, the host keeps running on port 8090 (set PORT to change it), and you can call any key:

curl -X POST localhost:8090/actors/Counter/2/method/inc \
  -H 'content-type: application/json' -d '[]'

--example ledger and --example saga work on wasmCloud too; see Examples.

The project#

PathContents
actor.moThe Counter actor type. Each key Counter/ID is a separate actor
host/moxzi's wasmCloud adapter. It's yours to change
run.shBuilds the actor and the host, starts what wasmCloud needs, and runs the demo

Change actor.mo and run ./run.sh again. New keys use the new code. Existing keys keep their code until they're upgraded; host/README.md describes upgrades.

How it maps#

Handled by
One message at a time per keyThe host
Actor statekv-store/ in the project directory
Durable timersA timer component that checks every 250 ms

State lives in the project directory, so deleting kv-store/ resets every actor.

Configuration#

VariableDefaultEffect
PORT8090The host's HTTP port
MOXZI_HOST_TOKENrandomToken for the host's control endpoints (/_moxzi/*)
On this pagePrerequisitesCreate and run a projectThe projectHow it mapsConfiguration