Skip to content

Commit 602fe78

Browse files
authored
Merge pull request #191 from KomodoPlatform/komodefi-cli
komodefi-cli tutorial
2 parents 7badbba + fef6a29 commit 602fe78

File tree

8 files changed

+532
-17
lines changed

8 files changed

+532
-17
lines changed

data-for-gpts/all-content.txt

+161-1
Original file line numberDiff line numberDiff line change
@@ -48906,7 +48906,8 @@ For a walkthrough covering multiple tutorials in a targeted fashion, please see
4890648906

4890748907
The AtomicDEX API section contains all available API commands.
4890848908

48909-
These API commands can also be called Remote Procedure Calls, or RPCs.
48909+
These API commands can also be called Remote Procedure Calls (or RPCs) and are used to interact with the AtomicDEX daemon using a variety of languages.
48910+
Recently, a `komodefi-cli` binary has been introduced to simplify the process of [interacting with the AtomicDEX daemon from the command line](/atomicdex/tutorials/using-komodefi-cli-in-console/).
4891048911
export const title = "Add and Activate Coins on AtomicDEX Mobile";
4891148912
export const description =
4891248913
"Activate coins on AtomicDEX Mobile by following simple steps and enjoy seamless trading.";
@@ -52449,6 +52450,165 @@ ssh -o IdentitiesOnly=yes -i ~/.ssh/mm2.pem admin@$nodeIp 'curl -s --url "http:/
5244952450
```
5245052451

5245152452
Edit the command above as necessary to exchange one curl command for another from [the AtomicDEX API.](/atomicdex/api/)
52453+
export const title = "Using KomoDeFi CLI in Console";
52454+
export const description = "This guide details the configuration and usage of the komodefi-cli binary.";
52455+
52456+
# Using KomoDeFi CLI in Console
52457+
52458+
For convenience, the standalone `komodefi-cli` binary is provided to be used for interacting with the KomoDeFi network from the command line.
52459+
52460+
## Building KomoDeFi CLI
52461+
52462+
Refer to [https://github.com/KomodoPlatform/komodo-defi-framework?tab=readme-ov-file#building-from-source](https://github.com/KomodoPlatform/komodo-defi-framework?tab=readme-ov-file#building-from-source) for instructions on installing dependencies and preparing your build environment.
52463+
52464+
Once it is ready, you can build the komodefi-cli binary by running the following command from the root folder of the project repository:
52465+
52466+
```bash
52467+
cargo build --manifest-path ./mm2src/komodefi_cli/Cargo.toml --out-dir $(pwd)/bin -Z unstable-options
52468+
```
52469+
52470+
We also add the `bin` directory to the `PATH` environment variable so that the `komodefi-cli` binary can be executed from any location.
52471+
52472+
```bash
52473+
export PATH=${PATH}:$(pwd)/bin
52474+
```
52475+
52476+
## Configuration
52477+
52478+
#### Setting Default CLI Root Path
52479+
52480+
You can customize the default root directory for `komodefi-cli` by setting the `KOMODEFI_CLI_ROOT` environment variable. This allows you to specify a location for saving configuration files, binaries, and other related data.
52481+
52482+
```bash
52483+
export KOMODEFI_CLI_ROOT=$HOME/komodefi-cli
52484+
```
52485+
52486+
#### Downloading the Core API binary
52487+
52488+
Before using the `komodefi-cli` binary, you need to download the Core API binary. Running the following command to download the latest release:
52489+
52490+
```bash
52491+
komodefi-cli mm2 download
52492+
```
52493+
52494+
#### Configuring the Core API
52495+
52496+
For the `komodefi-cli` to work, you need to configure the Core API by setting the `coins` data and the information required for an [MM2.json](/atomicdex/tutorials/atomicdex-walkthrough/#launching-the-atomic-dex-api) file. For more information, run the following command:
52497+
52498+
```bash
52499+
komodefi-cli init --help
52500+
```
52501+
52502+
Which will return
52503+
52504+
```bash
52505+
Config is not set
52506+
Initialize a predefined coin set and configuration to start mm2 instance with
52507+
52508+
Usage: komodefi-cli init [OPTIONS]
52509+
52510+
Options:
52511+
--mm-coins-path <MM_COINS_PATH> Coin set file path [default: coins] [aliases: coins]
52512+
--mm-conf-path <MM_CONF_PATH> mm2 configuration file path [default: MM2.json] [aliases: conf]
52513+
-h, --help Print help
52514+
```
52515+
52516+
If you have an existing coins file and/or MM2.json file, you can use the `--mm-coins-path` and `--mm-conf-path` options to specify the file paths, as below.
52517+
52518+
```bash
52519+
komodefi-cli init --mm-coins-path /path/to/coins --mm-conf-path /path/to/MM2.json
52520+
```
52521+
52522+
Alternatively, run `komodefi-cli init` without any options to create the `coins` and `MM2.json` files interactively. Pressing enter for each option will use the default values. In the case of the mnemonic phrase, you can enter your own mnemonic phrase or press enter to use a newly generated one.
52523+
52524+
```bash
52525+
$ komodefi-cli init
52526+
Config is not set
52527+
Start collecting mm2_cfg into: /home/smk762/komodefi-cli/MM2.json
52528+
> gui is set by default: komodefi-cli
52529+
> What is the network `mm2` is going to be a part, netid: 8762
52530+
> What is the seed phrase: before device quantum scan agent gift sauce flame devote tiny ripple west
52531+
> Allow weak password: No
52532+
> What is the rpc_password: <tb+UD32
52533+
> What is dbdir None
52534+
> Use secure connection for rpc: No
52535+
> What is rpcip: None
52536+
> What is the rpcport: 7783
52537+
> What is rpc_local_only:
52538+
> What is i_am_a_seed:
52539+
Reading seed nodes until tap enter is met
52540+
> What is the next seednode: None
52541+
> What is enable_hd:
52542+
mm2_cfg has been writen into: /home/smk762/komodefi-cli/MM2.json
52543+
Getting coin set from: https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins
52544+
Got coins data, written into: /home/smk762/komodefi-cli/coins
52545+
Start getting activation_scheme from: "/home/smk762/komodefi-cli/activation_scheme.json"
52546+
Download activation_scheme from: https://stats.kmd.io/api/table/coin_activation/
52547+
Initialization done
52548+
```
52549+
52550+
#### Starting the Core API
52551+
52552+
After the configuration is set, you can start the Core API by running `komodefi-cli mm2 start`. You can also use the `--help` option to see the available options for this command:
52553+
52554+
```bash
52555+
komodefi-cli mm2 start -help
52556+
Start mm2 instance
52557+
52558+
Usage: komodefi-cli mm2 start [OPTIONS]
52559+
52560+
Options:
52561+
--mm-conf-path <MM_CONF_PATH> mm2 configuration file path [aliases: conf]
52562+
--mm-coins-path <MM_COINS_PATH> Coin set file path [aliases: coins]
52563+
--mm-log <MM_LOG> Log file path [aliases: log]
52564+
-h, --help Print help
52565+
```
52566+
52567+
For example, to start the Core API and save its runtime logs to \~/logs/mm2.log, you can run the following command:
52568+
52569+
```bash
52570+
$ komodefi-cli mm2 start --mm-log ~/logs/mm2.log
52571+
> Set env MM_LOG as: ~/logs/mm2.log
52572+
> Started child process: "mm2", pid: 459264
52573+
```
52574+
52575+
## Usage
52576+
52577+
From here, you are ready to use the `komodefi-cli` binary to interact with the KomoDeFi network. You can use the `--help` option to see the available commands and options.
52578+
52579+
```bash
52580+
komodefi-cli --help
52581+
Config is not set
52582+
Provides a CLI interface and facilitates interoperating to komodo defi platform through the mm2 service
52583+
52584+
Usage: komodefi-cli <COMMAND>
52585+
52586+
Commands:
52587+
init Initialize a predefined coin set and configuration to start mm2 instance with
52588+
config Manage rpc_password and mm2 RPC URL
52589+
mm2 Manage mm2 instance commands
52590+
coin Coin commands: enable, disable etc.
52591+
wallet Wallet commands: balance, withdraw etc.
52592+
sell Put a selling request
52593+
buy Put a buying request
52594+
set-price Place an order on the orderbook. The setprice order is always considered a sell
52595+
update-maker-order Update order on the orderbook [aliases: update]
52596+
order Order listing commands: book, history, depth etc. [aliases: orders]
52597+
swaps Swap related commands [aliases: swap]
52598+
cancel Cancel one or many orders
52599+
utility Utility commands [aliases: util, pubkeys, pubkey]
52600+
message Message signing commands: sign, verify)
52601+
network Network commands
52602+
version-stat Version statistic commands [aliases: stat, vstat]
52603+
task Tracking the status of long-running commands
52604+
help Print this message or the help of the given subcommand(s)
52605+
52606+
Options:
52607+
-h, --help Print help
52608+
-V, --version Print version
52609+
```
52610+
52611+
For more details and examples of commands available in `komodefi-cli`, refer to the [komodefi-cli documentation](https://github.com/KomodoPlatform/komodo-defi-framework/blob/1799-swap-commands/mm2src/komodefi_cli/src/doc/CLI_REFERENCE.md) within the [Komodo DeFi Framework](https://github.com/KomodoPlatform/komodo-defi-framework) repository.
5245252612
export const title = "Chapter 00 - Bitcoin Protocol Basics";
5245352613
export const description = "Learn the basics of the Bitcoin protocol, including unspent transaction outputs (UTXOs) and the concept of the mempool, in this introductory chapter.";
5245452614

data-for-gpts/atomicdex-content.txt

+161-1
Original file line numberDiff line numberDiff line change
@@ -22212,7 +22212,8 @@ For a walkthrough covering multiple tutorials in a targeted fashion, please see
2221222212

2221322213
The AtomicDEX API section contains all available API commands.
2221422214

22215-
These API commands can also be called Remote Procedure Calls, or RPCs.
22215+
These API commands can also be called Remote Procedure Calls (or RPCs) and are used to interact with the AtomicDEX daemon using a variety of languages.
22216+
Recently, a `komodefi-cli` binary has been introduced to simplify the process of [interacting with the AtomicDEX daemon from the command line](/atomicdex/tutorials/using-komodefi-cli-in-console/).
2221622217
export const title = "Add and Activate Coins on AtomicDEX Mobile";
2221722218
export const description =
2221822219
"Activate coins on AtomicDEX Mobile by following simple steps and enjoy seamless trading.";
@@ -25755,3 +25756,162 @@ ssh -o IdentitiesOnly=yes -i ~/.ssh/mm2.pem admin@$nodeIp 'curl -s --url "http:/
2575525756
```
2575625757

2575725758
Edit the command above as necessary to exchange one curl command for another from [the AtomicDEX API.](/atomicdex/api/)
25759+
export const title = "Using KomoDeFi CLI in Console";
25760+
export const description = "This guide details the configuration and usage of the komodefi-cli binary.";
25761+
25762+
# Using KomoDeFi CLI in Console
25763+
25764+
For convenience, the standalone `komodefi-cli` binary is provided to be used for interacting with the KomoDeFi network from the command line.
25765+
25766+
## Building KomoDeFi CLI
25767+
25768+
Refer to [https://github.com/KomodoPlatform/komodo-defi-framework?tab=readme-ov-file#building-from-source](https://github.com/KomodoPlatform/komodo-defi-framework?tab=readme-ov-file#building-from-source) for instructions on installing dependencies and preparing your build environment.
25769+
25770+
Once it is ready, you can build the komodefi-cli binary by running the following command from the root folder of the project repository:
25771+
25772+
```bash
25773+
cargo build --manifest-path ./mm2src/komodefi_cli/Cargo.toml --out-dir $(pwd)/bin -Z unstable-options
25774+
```
25775+
25776+
We also add the `bin` directory to the `PATH` environment variable so that the `komodefi-cli` binary can be executed from any location.
25777+
25778+
```bash
25779+
export PATH=${PATH}:$(pwd)/bin
25780+
```
25781+
25782+
## Configuration
25783+
25784+
#### Setting Default CLI Root Path
25785+
25786+
You can customize the default root directory for `komodefi-cli` by setting the `KOMODEFI_CLI_ROOT` environment variable. This allows you to specify a location for saving configuration files, binaries, and other related data.
25787+
25788+
```bash
25789+
export KOMODEFI_CLI_ROOT=$HOME/komodefi-cli
25790+
```
25791+
25792+
#### Downloading the Core API binary
25793+
25794+
Before using the `komodefi-cli` binary, you need to download the Core API binary. Running the following command to download the latest release:
25795+
25796+
```bash
25797+
komodefi-cli mm2 download
25798+
```
25799+
25800+
#### Configuring the Core API
25801+
25802+
For the `komodefi-cli` to work, you need to configure the Core API by setting the `coins` data and the information required for an [MM2.json](/atomicdex/tutorials/atomicdex-walkthrough/#launching-the-atomic-dex-api) file. For more information, run the following command:
25803+
25804+
```bash
25805+
komodefi-cli init --help
25806+
```
25807+
25808+
Which will return
25809+
25810+
```bash
25811+
Config is not set
25812+
Initialize a predefined coin set and configuration to start mm2 instance with
25813+
25814+
Usage: komodefi-cli init [OPTIONS]
25815+
25816+
Options:
25817+
--mm-coins-path <MM_COINS_PATH> Coin set file path [default: coins] [aliases: coins]
25818+
--mm-conf-path <MM_CONF_PATH> mm2 configuration file path [default: MM2.json] [aliases: conf]
25819+
-h, --help Print help
25820+
```
25821+
25822+
If you have an existing coins file and/or MM2.json file, you can use the `--mm-coins-path` and `--mm-conf-path` options to specify the file paths, as below.
25823+
25824+
```bash
25825+
komodefi-cli init --mm-coins-path /path/to/coins --mm-conf-path /path/to/MM2.json
25826+
```
25827+
25828+
Alternatively, run `komodefi-cli init` without any options to create the `coins` and `MM2.json` files interactively. Pressing enter for each option will use the default values. In the case of the mnemonic phrase, you can enter your own mnemonic phrase or press enter to use a newly generated one.
25829+
25830+
```bash
25831+
$ komodefi-cli init
25832+
Config is not set
25833+
Start collecting mm2_cfg into: /home/smk762/komodefi-cli/MM2.json
25834+
> gui is set by default: komodefi-cli
25835+
> What is the network `mm2` is going to be a part, netid: 8762
25836+
> What is the seed phrase: before device quantum scan agent gift sauce flame devote tiny ripple west
25837+
> Allow weak password: No
25838+
> What is the rpc_password: <tb+UD32
25839+
> What is dbdir None
25840+
> Use secure connection for rpc: No
25841+
> What is rpcip: None
25842+
> What is the rpcport: 7783
25843+
> What is rpc_local_only:
25844+
> What is i_am_a_seed:
25845+
Reading seed nodes until tap enter is met
25846+
> What is the next seednode: None
25847+
> What is enable_hd:
25848+
mm2_cfg has been writen into: /home/smk762/komodefi-cli/MM2.json
25849+
Getting coin set from: https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins
25850+
Got coins data, written into: /home/smk762/komodefi-cli/coins
25851+
Start getting activation_scheme from: "/home/smk762/komodefi-cli/activation_scheme.json"
25852+
Download activation_scheme from: https://stats.kmd.io/api/table/coin_activation/
25853+
Initialization done
25854+
```
25855+
25856+
#### Starting the Core API
25857+
25858+
After the configuration is set, you can start the Core API by running `komodefi-cli mm2 start`. You can also use the `--help` option to see the available options for this command:
25859+
25860+
```bash
25861+
komodefi-cli mm2 start -help
25862+
Start mm2 instance
25863+
25864+
Usage: komodefi-cli mm2 start [OPTIONS]
25865+
25866+
Options:
25867+
--mm-conf-path <MM_CONF_PATH> mm2 configuration file path [aliases: conf]
25868+
--mm-coins-path <MM_COINS_PATH> Coin set file path [aliases: coins]
25869+
--mm-log <MM_LOG> Log file path [aliases: log]
25870+
-h, --help Print help
25871+
```
25872+
25873+
For example, to start the Core API and save its runtime logs to \~/logs/mm2.log, you can run the following command:
25874+
25875+
```bash
25876+
$ komodefi-cli mm2 start --mm-log ~/logs/mm2.log
25877+
> Set env MM_LOG as: ~/logs/mm2.log
25878+
> Started child process: "mm2", pid: 459264
25879+
```
25880+
25881+
## Usage
25882+
25883+
From here, you are ready to use the `komodefi-cli` binary to interact with the KomoDeFi network. You can use the `--help` option to see the available commands and options.
25884+
25885+
```bash
25886+
komodefi-cli --help
25887+
Config is not set
25888+
Provides a CLI interface and facilitates interoperating to komodo defi platform through the mm2 service
25889+
25890+
Usage: komodefi-cli <COMMAND>
25891+
25892+
Commands:
25893+
init Initialize a predefined coin set and configuration to start mm2 instance with
25894+
config Manage rpc_password and mm2 RPC URL
25895+
mm2 Manage mm2 instance commands
25896+
coin Coin commands: enable, disable etc.
25897+
wallet Wallet commands: balance, withdraw etc.
25898+
sell Put a selling request
25899+
buy Put a buying request
25900+
set-price Place an order on the orderbook. The setprice order is always considered a sell
25901+
update-maker-order Update order on the orderbook [aliases: update]
25902+
order Order listing commands: book, history, depth etc. [aliases: orders]
25903+
swaps Swap related commands [aliases: swap]
25904+
cancel Cancel one or many orders
25905+
utility Utility commands [aliases: util, pubkeys, pubkey]
25906+
message Message signing commands: sign, verify)
25907+
network Network commands
25908+
version-stat Version statistic commands [aliases: stat, vstat]
25909+
task Tracking the status of long-running commands
25910+
help Print this message or the help of the given subcommand(s)
25911+
25912+
Options:
25913+
-h, --help Print help
25914+
-V, --version Print version
25915+
```
25916+
25917+
For more details and examples of commands available in `komodefi-cli`, refer to the [komodefi-cli documentation](https://github.com/KomodoPlatform/komodo-defi-framework/blob/1799-swap-commands/mm2src/komodefi_cli/src/doc/CLI_REFERENCE.md) within the [Komodo DeFi Framework](https://github.com/KomodoPlatform/komodo-defi-framework) repository.

filepathSlugs.json

+10
Original file line numberDiff line numberDiff line change
@@ -3261,6 +3261,16 @@
32613261
"installation",
32623262
"create-an-ec-2-instance"
32633263
],
3264+
"src/pages/atomicdex/tutorials/using-komodefi-cli-in-console/index.mdx": [
3265+
"using-komo-de-fi-cli-in-console",
3266+
"building-komo-de-fi-cli",
3267+
"configuration",
3268+
"setting-default-cli-root-path",
3269+
"downloading-the-core-api-binary",
3270+
"configuring-the-core-api",
3271+
"starting-the-core-api",
3272+
"usage"
3273+
],
32643274
"src/pages/historical/cc-jl/chapter00/index.mdx": [
32653275
"chapter-00-bitcoin-protocol-basics"
32663276
],

src/data/sidebar.json

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@
149149
"title": "How to Update your Coins File",
150150
"href": "/atomicdex/tutorials/coins-file-update/"
151151
},
152+
{
153+
"title": "Using KomoDeFi-CLI in Console",
154+
"href": "/atomicdex/tutorials/using-komodefi-cli-in-console/"
155+
},
152156
{
153157
"title": "More Information About AtomicDEX",
154158
"href": "/atomicdex/tutorials/additional-information-about-atomicdex/"

src/pages/atomicdex/index.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ For a walkthrough covering multiple tutorials in a targeted fashion, please see
3434

3535
The AtomicDEX API section contains all available API commands.
3636

37-
These API commands can also be called Remote Procedure Calls, or RPCs.
37+
These API commands can also be called Remote Procedure Calls (or RPCs) and are used to interact with the AtomicDEX daemon using a variety of languages.
38+
Recently, a `komodefi-cli` binary has been introduced to simplify the process of [interacting with the AtomicDEX daemon from the command line](/atomicdex/tutorials/using-komodefi-cli-in-console/).

0 commit comments

Comments
 (0)