Skip to content

Commit e848017

Browse files
committed
finish draft for komodefi-cli
1 parent 6da8435 commit e848017

File tree

2 files changed

+147
-3
lines changed

2 files changed

+147
-3
lines changed

filepathSlugs.json

+4
Original file line numberDiff line numberDiff line change
@@ -3259,6 +3259,10 @@
32593259
"using-komo-de-fi-cli-in-console",
32603260
"building-komo-de-fi-cli",
32613261
"configuration",
3262+
"setting-default-cli-root-path",
3263+
"downloading-the-core-api-binary",
3264+
"configuring-the-core-api",
3265+
"starting-the-core-api",
32623266
"usage"
32633267
],
32643268
"src/pages/historical/cc-jl/chapter00/index.mdx": [

src/pages/atomicdex/tutorials/using-komodefi-cli-in-console/index.mdx

+143-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,158 @@ export const description = "This guide details the configuration and usage of th
33

44
# Using KomoDeFi CLI in Console
55

6-
For convenience, the KomoDeFi CLI is provided as a standalone binary that can be used to interact with the KomoDeFi network from the command line.
6+
For convenience, the standalone `komodefi-cli` binary is provided to be used for interacting with the KomoDeFi network from the command line.
77

88
## Building KomoDeFi CLI
99

1010
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.
1111

12-
Once it is ready, you can build the komodefi-cli binary by running the following command:
12+
Once it is ready, you can build the komodefi-cli binary by running the following command from the root folder of the project repository:
1313

1414
```bash
15-
cargo build --manifest-path ./mm2src/komodefi_cli/Cargo.toml
15+
cargo build --manifest-path ./mm2src/komodefi_cli/Cargo.toml --out-dir $(pwd)/bin -Z unstable-options
16+
```
17+
18+
We also add the `bin` directory to the `PATH` environment variable so that the `komodefi-cli` binary can be executed from any location.
19+
20+
```bash
21+
export PATH=${PATH}:$(pwd)/bin
1622
```
1723

1824
## Configuration
1925

26+
#### Setting Default CLI Root Path
27+
28+
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.
29+
30+
```bash
31+
export KOMODEFI_CLI_ROOT=$HOME/komodefi-cli
32+
```
33+
34+
#### Downloading the Core API binary
35+
36+
Before using the `komodefi-cli` binary, you need to download the Core API binary. Running the following command to download the latest release:
37+
38+
```bash
39+
komodefi-cli mm2 download
40+
```
41+
42+
#### Configuring the Core API
43+
44+
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:
45+
46+
```bash
47+
komodefi-cli init --help
48+
```
49+
50+
Which will return
51+
52+
```
53+
54+
Config is not set
55+
Initialize a predefined coin set and configuration to start mm2 instance with
56+
57+
Usage: komodefi-cli init [OPTIONS]
58+
59+
Options:
60+
--mm-coins-path <MM_COINS_PATH> Coin set file path [default: coins] [aliases: coins]
61+
--mm-conf-path <MM_CONF_PATH> mm2 configuration file path [default: MM2.json] [aliases: conf]
62+
-h, --help Print help
63+
```
64+
65+
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.
66+
67+
```bash
68+
komodefi-cli init --mm-coins-path /path/to/coins --mm-conf-path /path/to/MM2.json
69+
```
70+
71+
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.
72+
73+
```bash
74+
$ komodefi-cli init
75+
Config is not set
76+
Start collecting mm2_cfg into: /home/smk762/komodefi-cli/MM2.json
77+
> gui is set by default: komodefi-cli
78+
> What is the network `mm2` is going to be a part, netid: 8762
79+
> What is the seed phrase: before device quantum scan agent gift sauce flame devote tiny ripple west
80+
> Allow weak password: No
81+
> What is the rpc_password: <tb+UD32
82+
> What is dbdir None
83+
> Use secure connection for rpc: No
84+
> What is rpcip: None
85+
> What is the rpcport: 7783
86+
> What is rpc_local_only:
87+
> What is i_am_a_seed:
88+
Reading seed nodes until tap enter is met
89+
> What is the next seednode: None
90+
> What is enable_hd:
91+
mm2_cfg has been writen into: /home/smk762/komodefi-cli/MM2.json
92+
Getting coin set from: https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins
93+
Got coins data, written into: /home/smk762/komodefi-cli/coins
94+
Start getting activation_scheme from: "/home/smk762/komodefi-cli/activation_scheme.json"
95+
Download activation_scheme from: https://stats.kmd.io/api/table/coin_activation/
96+
Initialization done
97+
```
98+
99+
#### Starting the Core API
100+
101+
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:
102+
103+
```bash
104+
komodefi-cli mm2 start -help
105+
Start mm2 instance
106+
107+
Usage: komodefi-cli mm2 start [OPTIONS]
108+
109+
Options:
110+
--mm-conf-path <MM_CONF_PATH> mm2 configuration file path [aliases: conf]
111+
--mm-coins-path <MM_COINS_PATH> Coin set file path [aliases: coins]
112+
--mm-log <MM_LOG> Log file path [aliases: log]
113+
-h, --help Print help
114+
```
115+
116+
For example, to start the Core API and save its runtime logs to \~/logs/mm2.log, you can run the following command:
117+
118+
```bash
119+
$ komodefi-cli mm2 start --mm-log ~/logs/mm2.log
120+
> Set env MM_LOG as: ~/logs/mm2.log
121+
> Started child process: "mm2", pid: 459264
122+
```
123+
20124
## Usage
125+
126+
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.
127+
128+
```bash
129+
modefi-cli --help
130+
Config is not set
131+
Provides a CLI interface and facilitates interoperating to komodo defi platform through the mm2 service
132+
133+
Usage: komodefi-cli <COMMAND>
134+
135+
Commands:
136+
init Initialize a predefined coin set and configuration to start mm2 instance with
137+
config Manage rpc_password and mm2 RPC URL
138+
mm2 Manage mm2 instance commands
139+
coin Coin commands: enable, disable etc.
140+
wallet Wallet commands: balance, withdraw etc.
141+
sell Put a selling request
142+
buy Put a buying request
143+
set-price Place an order on the orderbook. The setprice order is always considered a sell
144+
update-maker-order Update order on the orderbook [aliases: update]
145+
order Order listing commands: book, history, depth etc. [aliases: orders]
146+
swaps Swap related commands [aliases: swap]
147+
cancel Cancel one or many orders
148+
utility Utility commands [aliases: util, pubkeys, pubkey]
149+
message Message signing commands: sign, verify)
150+
network Network commands
151+
version-stat Version statistic commands [aliases: stat, vstat]
152+
task Tracking the status of long-running commands
153+
help Print this message or the help of the given subcommand(s)
154+
155+
Options:
156+
-h, --help Print help
157+
-V, --version Print version
158+
```
159+
160+
For more deatils 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.

0 commit comments

Comments
 (0)