Start a Logos module from the CLI
Explore how to load and call a Logos module from the command line using logosctl.
This document is accurate for Testnet v0.3.
This guide covers how to build and install a Logos module, start the logosctl daemon, and call module methods from the command line. It is intended for users who want to run a module locally, or developers who want to test a module they are building. You create the module from the logos-module-builder template, so there is no code to write. By the end you will have a running logosctl instance that loads the template's minimal module and returns results from its greet and getStatus methods.
-
A supported OS:
- Linux x86_64 or aarch64
- macOS arm64 (Apple Silicon)
-
Git
-
logosctlinstalled.- Install it by running
curl -fsSL https://raw.githubusercontent.com/logos-co/logos-docs/main/resources/scripts/install-logosctl.sh | sudo sh
- Install it by running
-
Nix with flakes enabled.
- Install from nixos.org, then enable flakes:
mkdir -p ~/.config/nixecho 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf -
Basic familiarity with the command line and Nix concepts
What to expect
- You can build a module from the
logos-module-buildertemplate, load it into a runninglogosctldaemon and call its methods. - You can list the methods and events a module exposes, with the descriptions its author wrote.
- You have a
logosctlsession with amodulesdirectory that future modules install into.
Install the module
logosctl expects each module in its own subdirectory containing a manifest.json. logosctl package install handles this layout automatically when given an LGX package, and unpacks it into the current session's own modules/ directory.
-
Create a module from the
logos-module-buildertemplate and build its LGX package:mkdir hello-modulecd hello-modulenix flake init -t github:logos-co/logos-module-buildergit init && git add -Anix build '.#lgx-portable'cd ..- The template is a complete module named
minimal:src/minimal_impl.hdeclares its methods, and the build generates the rest. - Nix only sees files that Git tracks, so
git addcomes before the build. - Build
lgx-portable, notlgx: thelgxoutput is a development build (variantdarwin-arm64-devon Apple Silicon, for example) thatlogosctl package installrejects. See Troubleshooting.
- The template is a complete module named
-
Start the daemon, detached so this terminal stays free:
logosctl daemon start --detach- The detached command returns after the Logos node is ready to accept commands.
-
Check the status of
logosctl:logosctl daemon status -
Install the LGX package into the current session:
logosctl package install --file ./hello-module/result/*.lgxlogosctllists the change and asks you to confirm. Pass-yto skip the prompt. Without a terminal, for example in a script,-yis required.This unpacks into the
logosctlsession'smodules/directory:modules/minimal/├── minimal_plugin.dylib # (or .so on Linux)├── assets/lidl/minimal.lidl # The module's interface, in LIDL├── manifest.json # Package manifest├── variant # Platform variant identifier└── ... # Runtime libraries bundled by the portable build -
Confirm the module was installed correctly:
logosctl package lsminimalis listed with the sourceuser, next to the packages embedded inlogosctl.
Call module methods
With the module installed, load the module with logosctl and call its methods.
-
Load the module and confirm that it was loaded:
logosctl module load minimallogosctl module ls --loaded -
Call
greetwith a name:logosctl call minimal greet WorldHello, World! Greetings from the minimal module. -
Call
getStatus, which takes no arguments:logosctl call minimal getStatusMinimal module is running. -
Inspect the methods and events that
minimalexposes:logosctl module show minimalMethods:greet(name: tstr) -> tstrReturns a greeting and announces it as a typed `greeted` event.getStatus() -> tstrReturns a short status string....Events:greeted(greeting: tstr)Emitted by greet() with the greeting it produced. Other modulessubscribe with `modules().minimal.onGreeted(...)`.- The descriptions are the
///comments insrc/minimal_impl.h. - Every module also has
name(),version()andlidl(), which the output lists aftergetStatus.
- The descriptions are the
-
Stop the daemon:
logosctl daemon stop
Troubleshooting logosctl module startup
The platform key in manifest.json does not match
logosctl package install fails with an error such as:
Error: install failed at step 'install': Package does not contain variant for platform: darwin-arm64 (package provides: darwin-arm64-dev)
An LGX package holds one variant per platform, and the released logosctl installs only the portable variant for the platform it runs on. A -dev variant comes from the lgx output, so build lgx-portable instead. A variant for another platform means the package was built there; rebuild it on the target platform and reinstall.
The install is refused without confirmation
logosctl package install reports Refusing to proceed without confirmation. Pass -y to continue. when no terminal is available to confirm in. Pass -y.
The module is not loaded after a restart
Restarting the daemon does not reload modules, so logosctl call reports Module 'minimal' is not loaded. Load it again with logosctl module load minimal.