mirror of
https://github.com/logos-co/logos-docs.git
synced 2026-08-31 02:21:15 +00:00
153 lines
5.2 KiB
Markdown
153 lines
5.2 KiB
Markdown
---
|
|
title: Start a Logos module from the CLI
|
|
doc_type: procedure
|
|
product: core
|
|
topics: core
|
|
steps_layout: flat
|
|
authors: iurimatias, kashepavadan
|
|
owner: logos
|
|
doc_version: 1
|
|
slug: start-a-logos-module-from-the-cli
|
|
sidebar_position: 1
|
|
---
|
|
|
|
# Start a Logos module from the CLI
|
|
|
|
#### Explore how to load and call a Logos module from the command line using `logoscore`.
|
|
|
|
This guide covers how to build and install a Logos [module](https://docs.logos.co/get-started/glossary#module), start the `logoscore` daemon, and call module methods from the command line. It is intended for users who want to run an existing module, or developers who have already built a module binary and want to run it locally for testing or development. By the end you will have a running `logoscore` instance that loads [`accounts_module`](https://github.com/logos-co/logos-accounts-module) as an example module and returns results for mnemonic generation and relative strength.
|
|
|
|
**Before you start**, make sure you have the following:
|
|
|
|
- **Nix** with flakes enabled. Install from [nixos.org](https://nixos.org/download.html), then enable flakes:
|
|
|
|
```bash
|
|
mkdir -p ~/.config/nix
|
|
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
|
|
```
|
|
|
|
Verify: `nix flake --help >/dev/null 2>&1 && echo "Flakes enabled"`
|
|
- Git
|
|
- Linux or macOS
|
|
- [`logoscore`](https://github.com/logos-co/logos-logoscore-cli/releases/tag/0.2.0), [`lgpd`](https://github.com/logos-co/logos-package-downloader/releases/tag/0.2.0), and [`lgpm`](https://github.com/logos-co/logos-package-manager/releases/tag/0.2.0) installed. To install these tools, use the `install-node-tools.sh` helper script:
|
|
|
|
```bash
|
|
curl -fsSL https://raw.githubusercontent.com/logos-co/logos-docs/main/resources/scripts/install-node-tools.sh | sh
|
|
export PATH="$PWD/bin:$PATH"
|
|
```
|
|
|
|
## What to expect
|
|
|
|
- You can load `accounts_module` into a running `logoscore` daemon and call its methods.
|
|
- You can generate a BIP-39 mnemonic phrase and measure its entropy strength with no prior setup.
|
|
- You have a working local `modules` directory that `logoscore` can scan for future modules.
|
|
|
|
## Install the module
|
|
|
|
`logoscore` expects each module in its own subdirectory containing a `manifest.json`. The `lgpm` package manager handles this layout automatically when given an LGX package.
|
|
|
|
1. Clone the `logos-accounts-module` repository and build the LGX package:
|
|
|
|
```bash
|
|
git clone https://github.com/logos-co/logos-accounts-module.git
|
|
cd logos-accounts-module
|
|
|
|
nix build '.#lgx'
|
|
|
|
cd ..
|
|
```
|
|
|
|
1. Create the `modules` directory and copy the pre-loaded logos modules to it:
|
|
|
|
```bash
|
|
mkdir -p modules
|
|
cp -RL ./logos/modules/. ./modules/
|
|
```
|
|
|
|
1. Install the LGX package into the `modules` directory:
|
|
|
|
```bash
|
|
lgpm --modules-dir ./modules install --file ./logos-accounts-module/result/*.lgx
|
|
```
|
|
|
|
After installation, the directory structure looks like this:
|
|
|
|
```
|
|
modules/accounts_module/
|
|
├── accounts_module_plugin.dylib # (or .so on Linux)
|
|
├── manifest.json # Auto-generated by lgx
|
|
└── variant # Platform variant identifier
|
|
```
|
|
|
|
1. Confirm the module was installed correctly:
|
|
|
|
```bash
|
|
lgpm --modules-dir ./modules list
|
|
```
|
|
|
|
## Call module methods
|
|
|
|
With the module installed, start the [`logoscore`](https://github.com/logos-co/logos-logoscore-cli) daemon, load the module, and call its methods.
|
|
|
|
1. Start the daemon in the background, pointing it at the modules directory, and wait to initialise:
|
|
|
|
```bash
|
|
logoscore -D -m ./modules &
|
|
sleep 3
|
|
```
|
|
|
|
1. Check the status of `logoscore`:
|
|
|
|
```bash
|
|
logoscore status
|
|
```
|
|
|
|
1. Load the module and confirm that it was loaded:
|
|
|
|
```bash
|
|
logoscore load-module accounts_module
|
|
|
|
logoscore list-modules
|
|
```
|
|
|
|
1. Generate a random BIP-39 mnemonic phrase with 12 words:
|
|
|
|
```bash
|
|
logoscore call accounts_module createRandomMnemonic 12
|
|
```
|
|
|
|
1. Map a mnemonic word count to its entropy strength in bits — for example, 12 words is 128 bits.
|
|
|
|
```bash
|
|
logoscore call accounts_module lengthToEntropyStrength 12
|
|
```
|
|
|
|
1. Inspect all available methods in `accounts_module` with `module_info`:
|
|
|
|
```bash
|
|
logoscore module-info accounts_module
|
|
```
|
|
|
|
1. Stop the daemon:
|
|
|
|
```bash
|
|
logoscore stop
|
|
sleep 2
|
|
```
|
|
|
|
For inline (legacy) mode and other `logoscore` options, see the [Developer Guide — Running with logoscore](https://github.com/logos-co/logos-tutorial/blob/tutorial-v4/logos-developer-guide.md#61-running-with-logoscore).
|
|
|
|
## Troubleshooting `logoscore` module startup
|
|
|
|
### The modules directory is not found
|
|
|
|
Confirm the module subdirectory exists and contains a `manifest.json` file. Installing the package again with the correct `--modules-dir` path resolves this in most cases.
|
|
|
|
### The platform key in `manifest.json` does not match
|
|
|
|
`logoscore` matches the `main` object in `manifest.json` against your OS and architecture (for example, `linux-aarch64` or `darwin-arm64`). Rebuild the LGX package on the target platform and reinstall.
|
|
|
|
### The daemon does not respond after `sleep 3`
|
|
|
|
Increase the sleep duration if your machine is slow to initialise, or check for port conflicts by inspecting the daemon's stderr output.
|