On this page

latest contributor to this doc

Last Edit:

@smk762

Komodo DeFi API configuration

Komodo DeFi-API configuration parameters, along with additional runtime flags, and per-process environment variables are listed in the source code, and can be viewed by running the ./kdf --help.

When running the Komodo DeFi API via commandline with the kdf binary, some basic configuration parameters need to be defined in either an MM2.json file, or at runtime.

ParameterTypeDescription
1inch_apistringOptional, required if using 1inch integration methods. URL for 1inch API, e.g. "https://api.1inch.dev"
allow_weak_passwordbooleanOptional, defaults to false. If true, will allow low entropy rpc_password. If false rpc_password must not have 3 of the same characters in a row, must be between 8-32 characters in length, must contain at least one of each of the following: numeric, uppercase, lowercase, special character (e.g. !#$*). It also can not contain the word "password", or the chars <, >, or &.
dbdirstringOptional, defaults to a subfolder named DB in the path of your kdf binary. This path will store the Komodo DeFi-API database data.
disable_p2pbooleanOptional, defaults to false. If true, KDF will not attempt to use P2P for peer discovery, orderbook propagation and transmitting swap events. This is useful for running KDF in a controlled environment, such as a local network.
enable_hdbooleanOptional. If true, the Komodo DeFi-API will work in only the HD mode, and coins will need to have a coin derivation path entry in the coins file for activation. Defaults to false.
event_streaming_configurationobjectOptional, a standard EventStreamConfig object. Configuration for subscribing to events.
gas_apiobjectOptional, Used for EVM gas fee management. Contains fields for provider and url to source third party fee market information.
guistringInformation to identify which app, tool or product is using the API, e.g. KomodoWallet iOS 1.0.1. Helps developers identify if an issue is related to specific builds or operating systems etc.
httpsbooleanOptional. Only used with wss. Defaults to false, set to true to allow TLS/SSL enabled RPC (e.g. remote queries to a domain with a valid SSL certificate).
i_am_seedbooleanOptional, defaults to false. Runs Komodo DeFi Framework API as a seed node mode (acting as a relay for Komodo DeFi Framework API clients). Use of this mode is not reccomended on the main network (8762) as it could result in a pubkey ban if non-compliant. On alternative testing or private networks, at least one seed node is required to relay information to other Komodo DeFi Framework API clients using the same netID.
is_bootstrap_nodebooleanOptional, defaults to false. If true, and i_am_seed is also true, KDF will act as a bootstrap node for the network.
is_watcherbooleanOptional, defaults to false. If true, KDF will operate as a watcher seed nodes which may (in some cases) complete the final steps of a swap when a party goes offline.
message_service_cfgobjectOptional. This data is used to configure Telegram messenger alerts for swap events when running using the makerbot functionality. For more information check out the telegram alerts guide
metricsintegerOptional, defaults to 300. The interval in seconds which metrics are logged. Set to 0 to disable metrics.
myipaddrstringOptional. IP address to bind to for P2P networking.
netidintegerNework ID number, telling the Komodo DeFi Framework which network to join. 8762 is the current main network, though alternative netids can be used for testing or "private" trades as long as seed nodes exist to support it.
p2p_in_memorybooleanOptional, defaults to false. Enables in-memory peer-to-peer (P2P) networking mode. When set to true, the application bypasses traditional seed nodes and sets up in-memory relay for P2P communication. This is typically used in testing or isolated environments where external P2P communication is not desired.
p2p_in_memory_portintegerOptional (required when p2p_in_memory is true). Specifies the port number used by the in-memory relay node. This value is required if p2p_in_memory mode is active. It defines the local port for the relay to operate and accept in-memory peer connections.
passphrasestringOptional. Your passphrase (mnemonic phrase) in plain text. This is the source of each of your coins private keys. KEEP IT SAFE!. For more secure, encrypted storage in a local database, use the wallet_name and wallet_password parameters below.
prometheusportintegerOptional. Only used if you are logging metrics in Prometheus and Grafana. For more information check out the Komodo DeFi metrics guide
prometheus_credentialsintegerOptional. Only used if you are logging metrics in Prometheus and Grafana with authentication. For more information check out the Komodo DeFi metrics guide
rpccorsstringOptional, defaults to 'http://localhost:3000'. Access-Control-Allow-Origin header value to be used in all the RPC responses.
rpcipstringOptional, defaults to 127.0.0.1. IP address to bind to for RPC server.
rpc_passwordstringFor RPC requests that need authentication, this will need to match the userpass value in the request body.
rpcportintegerOptional, defaults to 7783. Port to use for RPC communication. If set to 0, an available port will be chosen randomly.
rpc_local_onlybooleanOptional, defaults to true. If false the Komodo DeFi Framework API will allow rpc methods sent from external IP addresses. Warning: Only use this if you know what you are doing, and have put the appropriate security measures in place.
seednodeslist of stringsThe domain or IP address of at least one seed node running on the same netid is required for KDF to launch (unless disable_p2p is set to true). Seednodes are used for peer discovery, orderbook propagation and transmitting swap events.
use_trading_proto_v2booleanOptional, defaults to false. If true, the Komodo DeFi-API will use the upgraded v2 trading protocol introduced in Komodo DeFi Framework v2.1.0-beta.
use_watchersbooleanOptional, defaults to true. If true, seed nodes may (in some cases) complete the final steps of a swap when a party goes offline.
wallet_namestringOptional. An arbitrary name for the wallet. If no passphrase is provided, and the wallet has been used already, the wallet_password will be used to decrypt the local stored mnemonic phrase. If it has not been used before, a mnemonic will be generated and encrypted for local storage. The mnemonic phrase can be seen in plain text using the (get_mnemonic)[/komodo-defi-framework/api/v20/get_mnemonic] method.
wallet_passwordstringOptional, required if using wallet_name. The password use to encrypt your wallet's mnemonic phrase for local storage, and decrypt the wallet when logging in.
wss_certsobjectOptional. Contains fields for server_priv_key and certificate to allow RPC or P2P communications over TLS/SSL.

A list of current seed nodes running on the 8762 netid can be sourced from https://github.com/KomodoPlatform/coins/blob/master/seed-nodes.json WASM nodes can only be run as a seed node when p2p_in_memory is true. In the 2.4.0-beta release of KDF, the event_stream_configuration has been renamed to event_streaming_configuration and no longer contains the active_events object. Rather than define the configuration for events in global config, a suite of new RPC methods to define streaming has been added which allows for much greater control over which events to track.

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "ENTER_UNIQUE_PASSWORD",
  "passphrase": "ENTER_UNIQUE_SEED_PHRASE_DONT_USE_THIS_CHANGE_IT_OR_FUNDS_NOT_SAFU",
  "allow_weak_password": true,
  "dbdir": "/path/to/DB/folder"
}

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd",
  "passphrase": "ENTER_UNIQUE_SEED_PHRASE_DONT_USE_THIS_CHANGE_IT_OR_FUNDS_NOT_SAFU",
  "allow_weak_password": false,
  "dbdir": "/path/to/DB/folder"
}

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd",
  "passphrase": "ENTER_UNIQUE_SEED_PHRASE_DONT_USE_THIS_CHANGE_IT_OR_FUNDS_NOT_SAFU",
  "gas_api": {
    "provider": "infura",
    "url": https://your-provider-url.com
  }
}

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd",
  "passphrase": "ENTER_UNIQUE_SEED_PHRASE_DONT_USE_THIS_CHANGE_IT_OR_FUNDS_NOT_SAFU",
  "wss_certs": {
    "server_priv_key": "/path/to/privkey.pem",
    "certificate": "/path/to/fullchain.pem"
  }

}

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd",
  "wallet_name": "Gringotts Retirement Fund",
  "wallet_password": "Q^wJZg~Ck3.tPW~asnM-WrL"
}

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd",
  "1inch_api": "https://api.1inch.dev"
}

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd"
  "event_streaming_configuration": {
      "access_control_allow_origin": "*",
      "worker_path": "index.js"
  }
}

To use methods which interface with the 1inch API, you'll also need to set your 1inch API key as an environment variable called ONE_INCH_API_TEST_AUTH, e.g. ONE_INCH_API_TEST_AUTH="Bearer YourAPIkey".

As this feature is still experimental, you will need to build KDF from source on the dev branch with a build flag, e.g. cargo build --features test-ext-api.

If you are using HD wallets, you will need to set enable_hd to true in to your MM2.json file.

Using the same seed phrase with / without setting enable_hd to true will result in different addresses being generated. For example, when using the seed phrase february soldier message acid member jump shadow walk novel impose puppy tornado: - If enable_hd is true in your MM2.json, the first address in the wallet returns the address 0x26cE5D1cD4CC673a1b0b980371C7c862B9503452 for ETH - If the enable_hd is false (or not set), the wallet will return the address 0x8c40a6E127c7a13e26ce95deA88354C3fb134580 for ETH

{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "rpc_password": "Ent3r_Un1Qu3_Pa$$w0rd",
  "passphrase": "ENTER_UNIQUE_SEED_PHRASE_DONT_USE_THIS_CHANGE_IT_OR_FUNDS_NOT_SAFU",
  "allow_weak_password": false,
  "dbdir": "/path/to/DB/folder",
  "enable_hd": true
}

For bootstrap nodes:

  • set is_bootstrap_node to true.
  • the seednodes list paramater is not required.
  • the i_am_seed paramater must be set to true.
  • the disable_p2p paramater must be set to false.
{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "is_bootstrap_node": true,
  "i_am_seed": true,
  "disable_p2p": false
}

For a normal seed node:

  • set is_bootstrap_node to false.
  • the seednodes list paramater is required.
  • the i_am_seed paramater must be set to true.
  • the disable_p2p paramater must be set to false.
{
  "gui": "DEVDOCS_CLI",
  "netid": 8762,
  "seednodes": ["seed01.kmdefi.net", "seed02.kmdefi.net"],
  "is_bootstrap_node": false,
  "i_am_seed": true,
  "disable_p2p": false
}

Some warning or errors may appear in logs on launch if these parameters are not set correctly.

  • WARN P2P is disabled. Features that require a P2P network (like swaps, peer health checks, etc.) will not work.
  • P2P initializing error: 'Precheck failed: 'Seed nodes cannot disable P2P.'
  • P2P initializing error: 'Precheck failed: 'Bootstrap node must also be a seed node.'
  • Precheck failed: 'Non-bootstrap node must have seed nodes configured to connect.'

From v2.5.0-beta, there will be no default seed nodes, and the seednodes list parameter will be required, unless disable_p2p is set to true. In this state, all KDF functionality related to orderbooks, swaps, and peer discovery will be disabled, but coins can still be activated and transactions can still be sent.

You can download and use this file as a starting point for your own coins file. It contains all of the coins that are currently supported by the Komodo DeFi API, and is maintained by the Komodo Platform team. The structure for adding additional coins can vary, please refer to the listing guide or contact the KomodoPlatform team for assistance.

VariableTypeDescription
ONE_INCH_API_TEST_AUTHstring1inch API key to authenticate for using 1inch integration methods.
MM2_CONF_PATHstringA file path to load the MM2.json configuration file. Defaults to MM2.json in the same folder as the kdf binary.
MM_COINS_PATHstringA file path to load the coins configuration file. A comprehensive version for public use is maintained in the Komodo Platform coins github repository
MM_LOGstringA file path to store the Komodo DeFi-API logs.
MM_CERT_PATHstringFull path to TLS/SSL certificate file.
MM_CERT_KEY_PATHstringFull path to TLS/SSL certificate key file.
RUST_LOGstringGlobal default log level is info. To modify the log level for specific module (e.g. for debugging atomicdex_gossipsub::behaviour) and keep the default at info, use the format "info,atomicdex_gossipsub::behaviour=debug"
USERPASSstringFor convenience, this variable can store the value of your rpc_password to be referenced in any shell scripts

Check out the rest of the Komodo DeFi API documentation for examples of how to:

If you have any questions or feedback, join us on the Komodo Platform Discord Server and tell us about your experience!