Skip to main content

Using Dev Mode in meroctl CLI

Overview​

The meroctl CLI provides a powerful feature called "dev mode" that allows developers to test their applications locally before publishing them to the network. This mode is particularly useful during the development and testing phases of your application.

All of the communication with your node through the meroctl CLI is protected by your nodes private key.

Why Use Dev Mode?​

Dev mode offers several advantages:

  1. Local Testing: Test your application on your local machine without needing to publish it to the network.
  2. Quick Iterations: Make changes to your application and immediately test them without going through the full publication process.
  3. Context Creation: Automatically create a context and link it to your local application.
  4. Hot Reload-like Functionality: Any changes to the binary will automatically reflect in the context, eliminating the need to "upload" the app again after every change.

Prerequisites​

Before using dev mode, ensure you have a node and a coordinator node running. This should be done in a separate terminal window. For more information, see the Setup guide.

How to Use Dev Mode​

To list all supported commands for the deamon, run the following command:

Terminal
cargo run -p merod -- help

To list all supported commands for the cli, run the following command:

Terminal
cargo run -p meroctl -- help

Supported commands:

  • context Manage contexts
  • app Manage applications
  • help Print this message or the help of the given subcommand(s)

Here's the basic syntax:

All commands share the same prefix:

Terminal
cargo run -p meroctl -- --home <path_to_home> --node-name <node_name> <command>

Parameters:​

  • --home: Specifies the path to the home directory. ( In our example we are using data as the home directory)

  • --node-name: Specifies the name of the node.

  • --path: Specifies the absolute path to your WASM file.

Create dev context using installed app

Terminal
cargo run -p meroctl -- --home <path_to_home> --node-name <node_name> context create --watch <path>

Output

Terminal
$ cargo run -p meroctl -- --home data --node-name node1 context create  --watch ./path/to/binary.wasm
Application `<appId>` installed!
Context `<contextId>` created!
Context{contextId} -> Application{appId}
(i) Watching for changes to "./path/to/binary.wasm"

Invite coordinator or other local nodes to participate in the context

Terminal
cargo run -p  meroctl -- --node-name coordinator --home data  context join --context-id contextId

Output

Terminal
Context <contextId> sucesfully joined

Create context command will:

  1. Install your application locally.
  2. Create a new context.
  3. Link the context to your local application.

Automatic Updates​

One of the key benefits of dev mode is its ability to automatically reflect changes in your application. When you modify and recompile your WASM binary, these changes are immediately available in the context without requiring you to "upload" or reinstall the application. This feature provides a seamless development experience, similar to "hot reload" functionality in other development environments.

Other useful commands​

  1. List existing contexts
Terminal
$ cargo run -p meroctl -- --home data --node-name node1 context ls
  1. Create a context for a published application:
Terminal
$ cargo run -p meroctl -- --home data --node-name node1 context create --application-id <appId>

Output

Terminal
Context `contextId` created!
Context{contextId} -> Application{appId}

From development to Publication​

When you're ready to move from local development to publishing your application:

  1. Test your application thoroughly using dev mode.

  2. When satisfied with your application's performance, follow the steps in the Publish App guide to publish your application to the network.

  3. After publication, you can create contexts for your published application using the --application-id flag instead of dev mode.

Install the local app on node for debugging

Terminal
cargo run -p meroctl -- --home <path_to_home> --node-name <node_name> app install –-path <path>

Output

Terminal
Application installed successfully. Application ID: <appId>
Was this page helpful?
Need some help? Check Support page