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:
- Local Testing: Test your application on your local machine without needing to publish it to the network.
- Quick Iterations: Make changes to your application and immediately test them without going through the full publication process.
- Context Creation: Automatically create a context and link it to your local application.
- 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:
cargo run -p merod -- help
To list all supported commands for the cli, run the following command:
cargo run -p meroctl -- help
Supported commands:
context
Manage contextsapp
Manage applicationshelp
Print this message or the help of the given subcommand(s)
Here's the basic syntax:
All commands share the same prefix:
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 usingdata
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
cargo run -p meroctl -- --home <path_to_home> --node-name <node_name> context create --watch <path>
Output
$ 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
cargo run -p meroctl -- --node-name coordinator --home data context join --context-id contextId
Output
Context <contextId> sucesfully joined
Create context command will:
- Install your application locally.
- Create a new context.
- 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​
- List existing contexts
$ cargo run -p meroctl -- --home data --node-name node1 context ls
- Create a context for a published application:
$ cargo run -p meroctl -- --home data --node-name node1 context create --application-id <appId>
Output
Context `contextId` created!
Context{contextId} -> Application{appId}
From development to Publication​
When you're ready to move from local development to publishing your application:
-
Test your application thoroughly using dev mode.
-
When satisfied with your application's performance, follow the steps in the Publish App guide to publish your application to the network.
-
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
cargo run -p meroctl -- --home <path_to_home> --node-name <node_name> app install –-path <path>
Output
Application installed successfully. Application ID: <appId>