Quickstart
This walks from an empty crate to a method call. The two binaries you use are
merod (the node daemon — init, run) and meroctl (the operator
CLI — app, context, namespace, call).
1. Write and build the app
Section titled “1. Write and build the app”-
Scaffold an app with the cargo mero toolchain:
Terminal window cargo mero new my-appcd my-appThis writes a ready-to-build crate:
Cargo.toml(SDK pins, the app-id metadata, and the build profiles), a workingsrc/lib.rs, and a TestHost test. The tutorial walks the generated manifest field by field. -
The generated
src/lib.rsis already a working app: a state struct plus methods. This is the shape every Calimero app follows (see SDK macros):use calimero_sdk::app;use calimero_storage::collections::{LwwRegister, UnorderedMap};#[app::state]pub struct KvStore {items: UnorderedMap<String, LwwRegister<String>>,}#[app::logic]impl KvStore {#[app::init]pub fn init() -> KvStore {KvStore { items: UnorderedMap::new() }}pub fn set(&mut self, key: String, value: String) -> app::Result<()> {self.items.insert(key, value.into())?;Ok(())}#[app::view]pub fn get(&self, key: String) -> app::Result<Option<String>> {Ok(self.items.get(&key)?.map(|v| v.get().clone()))}} -
Build to WASM with the cargo mero toolchain:
Terminal window cargo mero buildOne command compiles, optimizes, and embeds the ABI; the wasm lands at
res/<crate_name>.wasm, ready to bundle.
2. Run a node
Section titled “2. Run a node”-
Initialize a node’s config and data directory, then run it:
Terminal window merod --node node1 init --server-port 2428 --swarm-port 2528merod --node node1 runmerod --node node1 init --helplists the full set (swarm/server host and port, boot nodes, mDNS, auth mode). Config and data live underCALIMERO_HOME/--home.
3. Install the app, attach a context, call a method
Section titled “3. Install the app, attach a context, call a method”meroctl talks to a running node. Select the node with --node node1 (a
configured alias) or --api <URL>.
-
Install the WASM module. The node returns an application id:
Terminal window meroctl --node node1 app install \--path ./res/my_app.wasm \--package com.example.myapp \--version 1.0.0List what is installed with
meroctl --node node1 app ls.Installing the raw wasm is the fast dev loop; for a signed, distributable
.mpkruncargo mero bundleand pass the bundle to--pathinstead - see Packaging & signing. -
Attach the app to a context. A context is a running instance of an app over a shared state. The simplest entry is to create a namespace bound to the application id:
Terminal window meroctl --node node1 namespace create --application-id <app-id> -
Call a method on the context. Mutations and views both go through the top-level
callcommand — whether a call mutates or is a read-only view is decided by the method’s own#[app::view]marker, not a CLI flag:Terminal window # mutatemeroctl --node node1 call set \--context <context-id> \--args '{"key": "hello", "value": "world"}'# viewmeroctl --node node1 call get \--context <context-id> \--args '{"key": "hello"}'--argstakes JSON matching the method’s parameters.<context-id>accepts a context id or an alias you created with--name.
These three commands trace one path from a built artifact to a method result — install the code, attach a context over shared state, then call into it: