Coin Activation

There are two methods of coin activation:

  • enable - Connects to a native daemon, or a url which handles RPCs for Platform coins (e.g. ETH, MATIC, FTM, BNB, ONE)
  • electrum - Connects to an electrum server for UTXO based coins and QTUM/QRC20 tokens.

A coin can only be activated once per session, and must be activated before it can be used in trading or wallet functions.

Native mode activation

If you are running a UTXO based coin daemon locally and the blockchain is synchronised, you can connect the local daemon to the Komodo DeFi Framework API by using the enable method, though some additional configuration is required. The Komodo DeFi Framework API requires the following options to be added to the native chain’s .conf file.

logevents=1
txindex=1
addressindex=1

Lite mode activation

Activating coins in ‘lite mode’ means you don’t need to have a native coin daemon installed, or keep a local blockchain synchronised. In this mode, the Komodo DeFi Framework API communicates with an external node to perform transactions and query the blockchain. UTXO based coins and QTUM/QRC20 tokens communicate via electrum servers, while other platform coins communicate via JSON RPC urls.

Komodo DeFi Framework is a true cross chain, cross protocol Decentralized Exchange (DEX), allowing for trades between coins and tokens across many platforms and ecosystems, such as:

Electrum

Arguments

Parameter Type Required Default Description
coin string Ticker of coin to activate
servers list of objects A list of standard ActivationServers objects.
mm2 integer Required if not set in coins file. Informs the Komodo DeFi Framework API whether or not the coin is expected to function. Accepted values are 0 or 1
min_connected integer 1 Minimum number of electrum servers to maintain an active connection to.
max_connected integer Maximum number of electrum servers to maintain an active connection to. If not set, defaults to all servers in activation request.
required_confirmations integer 3 Number of confirmations for the Komodo DeFi Framework API to wait during the transaction steps of an atomic swap.
requires_notarization boolean false If true, coins protected by Komodo Platform's dPoW security will wait for a notarization before progressing to the next atomic swap transactions step.
swap_contract_address string QRC20 only. Address of etomic swap smart contract
fallback_swap_contract string QRC20 only. Address of backup etomic swap smart contract
utxo_merge_params object A standard UtxoMergeParams object. Used to reduce a wallet's UTXO count in cases where it is causing significantly slower RPC responses.

Response

Parameter Type Required Description
address string the address of the user's coin wallet, based on the user's passphrase
balance string (numeric) the amount of coin the user holds in their wallet; does not include unspendable_balance
unspendable_balance string (numeric) the coin balance that is unspendable at the moment (e.g. if the address has immature UTXOs)
coin string the ticker of the enabled coin
required_confirmations number the number of transaction confirmations for which the Komodo DeFi Framework API must wait during the atomic swap process
mature_confirmations number the number of coinbase transaction confirmations required to become mature; UTXO coins only
requires_notarization bool whether the node must wait for a notarization of the selected coin that is performing the atomic swap transactions; applicable only for coins using Komodo dPoW
result string the result of the request; this value either indicates success, or an error, or another type of failure

📌 Examples

UTXO coin activationlegacyelectrum

POST Electrum Method electrum
{
  "coin": "BCH",
  "method": "electrum",
  "servers": [
    {
      "url": "bch.electrum3.cipig.net:10055",
      "protocol": "TCP"
    },
    {
      "url": "bch.electrum3.cipig.net:20055",
      "protocol": "SSL"
    },
    {
      "url": "bch.electrum3.cipig.net:30055",
      "protocol": "WSS"
    }
  ],
  "min_connected": 1,
  "max_connected": 2,
  "userpass": "RPC_UserP@SSW0RD"
}

Response Success

{
  "address": "1DgpBvyeUNHasBt3h3qzC1p9Z8qTgr6t5m",
  "balance": "0.12345678",
  "required_confirmations": 1,
  "requires_notarization": false,
  "result": "success"
}
Show Error Responses (1)

Error Connection failed

Unable to connect to electrum servers

{
  "error": "All electrum servers for BCH are unavailable"
}

UTXO coin activation with required_confirmations, requires_notarization and mm2 argumentslegacyelectrum

POST Electrum Method electrum
{
  "coin": "KMD",
  "method": "electrum",
  "servers": [
    {
      "url": "kmd.electrum3.cipig.net:10001",
      "protocol": "TCP"
    },
    {
      "url": "kmd.electrum1.cipig.net:20001",
      "protocol": "SSL"
    },
    {
      "url": "kmd.electrum3.cipig.net:20001",
      "protocol": "SSL"
    }
  ],
  "required_confirmations": 10,
  "requires_notarization": true,
  "mm2": 1,
  "userpass": "RPC_UserP@SSW0RD"
}

Response Success

{
  "coin": "KMD",
  "address": "RQNUR7qLgPUgZxYbvU9x5Kw93f6LU898CQ",
  "balance": "762",
  "unspendable_balance": "0",
  "mature_confirmations": 100,
  "required_confirmations": 10,
  "requires_notarization": true,
  "result": "success"
}
Show Error Responses (3)

Error Missing mm2 parameter

mm2 param is not set in coins config or enable request

{
  "error": "lp_coins:943] lp_coins:693] mm2 param is not set neither in coins config nor enable request, assuming that coin is not supported"
}

Error Invalid min_connected

min_connected should be greater than 0

{
  "error": "rpc:184] dispatcher_legacy:141] lp_commands_legacy:141] lp_coins:4462] utxo_standard:73] utxo_coin_builder:616] Internal error: manager:129] min_connected should be greater than 0"
}

Error Invalid connection range

min_connected must be <= max_connected

{
  "error": "rpc:184] dispatcher_legacy:141] lp_commands_legacy:141] lp_coins:4462] utxo_standard:73] utxo_coin_builder:616] Internal error: manager:132] min_connected (2) must be <= max_connected (1)"
}

QTUM/QRC20 coin activationlegacyelectrum

POST Electrum Method electrum
{
  "coin": "QTUM",
  "method": "electrum",
  "servers": [
    {
      "url": "qtum.electrum1.cipig.net:20050",
      "protocol": "SSL"
    },
    {
      "url": "qtum.electrum2.cipig.net:20050",
      "protocol": "SSL"
    },
    {
      "url": "qtum.electrum2.cipig.net:10050",
      "protocol": "TCP"
    }
  ],
  "swap_contract_address": "0x2f754733acd6d753731c00fee32cb484551cc15d",
  "userpass": "RPC_UserP@SSW0RD"
}

Response Success

{
  "coin": "QTUM",
  "address": "QjXkGgoiycYRm2NbiMpkEHuQt7SB9BKHjz",
  "balance": "7.77",
  "required_confirmations": 3,
  "requires_notarization": false,
  "unspendable_balance": "0",
  "mature_confirmations": 100,
  "result": "success"
}
Show Error Responses (1)

Error Missing mm2 parameter

mm2 param is not set in coins config or enable request

{
  "error": "lp_coins:943] lp_coins:693] mm2 param is not set neither in coins config nor enable request, assuming that coin is not supported"
}

Error responses

If mm2 is not set in either the command or your coins file, you will see the following error:

{
  "error": "lp_coins:943] lp_coins:693] mm2 param is not set neither in coins config nor enable request, assuming that coin is not supported"
}

If min_connected is < 1, you will see the following error:

{
  "error":"rpc:184] dispatcher_legacy:141] lp_commands_legacy:141] lp_coins:4462] utxo_standard:73] utxo_coin_builder:616] Internal error: manager:129] min_connected should be greater than 0"
}

If max_connected is < min_connected, you will see the following error:

{
  "error": "rpc:184] dispatcher_legacy:141] lp_commands_legacy:141] lp_coins:4462] utxo_standard:73] utxo_coin_builder:616] Internal error: manager:132] min_connected (2) must be <= max_connected (1)"
}

Enable

Arguments

Parameter Type Required Default Description
coin string the name of the coin the user desires to enable
urls array of strings required for ETH/ERC20 and other gas model chains - urls of Ethereum RPC nodes to which the user desires to connect
swap_contract_address string required for QRC20 only - address of etomic swap smart contract
fallback_swap_contract string required for QRC20 only - address of backup etomic swap smart contract
gas_station_decimals integer 8 optional for ETH/ERC20 and other gas model chains - Defines the decimals used to denominate the gas station response to gwei units. For example, the ETH gas station uses 8 decimals, which means that "average": 860 is equal to 86 gwei. While the Matic gas station uses 9 decimals, so 860 would mean 860 gwei exactly.
gas_station_policy.policy string MeanAverageFast optional for ETH/ERC20 and other gas model chains - Defines the method of gas price calculation from the station response. "MeanAverageFast" will use the mean between average and fast fields. "Average" will return a simple average value.
mm2 integer Required if not set in coins file. Informs the Komodo DeFi Framework API whether or not the coin is expected to function. Accepted values are 0 or 1
tx_history bool If true the Komodo DeFi Framework API will preload transaction history as a background process. Must be set to true to use the my_tx_history method
required_confirmations integer 3 Number of confirmations for the Komodo DeFi Framework API to wait during the transaction steps of an atomic swap.
requires_notarization boolean false If true, coins protected by Komodo Platform's dPoW security will wait for a notarization before progressing to the next atomic swap transactions step.

Response

Parameter Type Required Description
address string the address of the user's coin wallet, based on the user's passphrase
balance string (numeric) the amount of coin the user holds in their wallet; does not include unspendable_balance
unspendable_balance string (numeric) the coin balance that is unspendable at the moment (e.g. if the address has immature UTXOs)
coin string the ticker of enabled coin
required_confirmations number Komodo DeFi Framework API will wait for the this number of coin's transaction confirmations during the swap
requires_notarization bool whether the node must wait for a notarization of the selected coin that is performing the atomic swap transactions
mature_confirmations number the number of coinbase transaction confirmations required to become mature; UTXO coins only
result string the result of the request; this value either indicates success, or an error or other type of failure

📌 Examples

Native UTXO coin activationlegacyenable

POST Enable Method enable
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable",
  "coin": "TKL"
}

Response Success

{
  "coin": "TKL",
  "address": "RQNUR7qLgPUgZxYbvU9x5Kw93f6LU898CQ",
  "balance": "333",
  "required_confirmations": 1,
  "requires_notarization": false,
  "unspendable_balance": "0",
  "mature_confirmations": 100,
  "result": "success"
}
Show Error Responses (1)

Error Connection failed

Unable to connect to daemon

{
  "error": "Failed to connect to native daemon"
}

Command (With required_confirmations, requires_notarization and mm2 arguments)

POST enable
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable",
  "coin": "TKL",
  "mm2": 1,
  "required_confirmations": 10,
  "requires_notarization": true
}

Response Success

{
  "coin": "TKL",
  "address": "RQNUR7qLgPUgZxYbvU9x5Kw93f6LU898CQ",
  "balance": "777",
  "required_confirmations": 10,
  "requires_notarization": true,
  "unspendable_balance": "0",
  "mature_confirmations": 100,
  "result": "success"
}
Show Error Responses (1)

Error Connection failed

Unable to connect to daemon

{
  "error": "Failed to connect to native daemon"
}

Command (for Ethereum and ERC20-based blockchains)

POST enable
{
  "coin": "ETH",
  "method": "enable",
  "urls": [
    "https://eth3.cipig.net:18555",
    "https://mainnet.gateway.tenderly.co",
    "https://ethereum-rpc.publicnode.com"
  ],
  "swap_contract_address": "0x24ABE4c71FC658C91313b6552cd40cD808b3Ea80",
  "fallback_swap_contract": "0x8500AFc0bc5214728082163326C2FF0C73f4a871",
  "userpass": "RPC_UserP@SSW0RD"
}

Response Success

{
  "address": "0x7Bc1bBDD6A0a722fC9bffc49c921B685ECB84b94",
  "balance": "12.00283000",
  "locked_by_swaps": "0.00000000",
  "required_confirmations": 1,
  "requires_notarization": false,
  "mature_confirmations": 0,
  "result": "success"
}
Show Error Responses (2)

Error Transport error

Connection to ETH node failed

{
  "error": "Transport error: JsonRpcError { client_info: \"coin: ETH\", request: JsonRpcRequest { jsonrpc: \"2.0\", id: \"9\", method: \"eth_getBalance\", params: [String(\"0x7Bc1bBDD6A0a722fC9bffc49c921B685ECB84b94\"), String(\"latest\")] }, error: Transport(\"All electrum servers unavailable!\") }"
}

Error Already enabled

The coin is already activated

{
  "error": "lp_coins:1308] eth:295] Coin ETH is already activated"
}

EVM coin activation with gas_station_url and policylegacyenable

POST Enable Method enable
{
  "coin": "ETH",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable",
  "urls": [
    "https://eth3.cipig.net:18555",
    "https://0xrpc.io/eth",
    "https://eth.drpc.org"
  ],
  "swap_contract_address": "0x24ABE4c71FC658C91313b6552cd40cD808b3Ea80",
  "fallback_swap_contract": "0x8500AFc0bc5214728082163326C2FF0C73f4a871",
  "gas_station_url": "https://ethgasstation.info/json/ethgasAPI.json",
  "gas_station_decimals": 8,
  "gas_station_policy": {
    "policy": "MeanAverageFast"
  }
}

Response Success

{
  "coin": "ETH",
  "address": "0x3c7aad7b693e94f13b61d4be4abaeaf802b2e3b5",
  "balance": "50",
  "required_confirmations": 1,
  "requires_notarization": false,
  "unspendable_balance": "0",
  "result": "success"
}
Show Error Responses (2)

Error Gas station error

Unable to fetch gas price from station

{
  "error": "Failed to get gas price from station"
}

Error Already enabled

The coin is already activated

{
  "error": "lp_coins:1308] eth:295] Coin ETH is already activated"
}

Polygon (MATIC) and PLG20 activationlegacyenable

POST Enable Method enable
{
  "coin": "NZDS-PLG20",
  "method": "enable",
  "swap_contract_address": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
  "fallback_swap_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
  "urls": [
    "https://node.komodo.earth:8080/polygon",
    "https://pol3.cipig.net:18755",
    "https://polygon.gateway.tenderly.co"
  ],
  "userpass": "RPC_UserP@SSW0RD"
}

Response Success

{
  "coin": "NZDS-PLG20",
  "address": "0x3c7aad7b693e94f13b61d4be4abaeaf802b2e3b5",
  "balance": "350",
  "required_confirmations": 1,
  "requires_notarization": false,
  "unspendable_balance": "0",
  "result": "success"
}
Show Error Responses (2)

Error Connection failed

Unable to connect to Polygon RPC

{
  "error": "All Polygon RPC servers unavailable"
}

Error Already enabled

The coin is already activated

{
  "error": "lp_coins:1308] Coin NZDS-PLG20 is already activated"
}

Binance Coin (BNB) and BEP20 activationlegacyenable

POST Enable Method enable
{
  "coin": "BUSD-BEP20",
  "method": "enable",
  "swap_contract_address": "0xeDc5b89Fe1f0382F9E4316069971D90a0951DB31",
  "fallback_swap_contract": "0xeDc5b89Fe1f0382F9E4316069971D90a0951DB31",
  "urls": [
    "https://bsc1.cipig.net:18655",
    "https://bsc2.cipig.net:18655",
    "https://bsc3.cipig.net:18655"
  ],
  "userpass": "RPC_UserP@SSW0RD"
}

Response Success

{
  "coin": "BUSD-BEP20",
  "address": "0x3c7aad7b693e94f13b61d4be4abaeaf802b2e3b5",
  "balance": "45",
  "required_confirmations": 1,
  "requires_notarization": false,
  "unspendable_balance": "0",
  "result": "success"
}
Show Error Responses (2)

Error Connection failed

Unable to connect to BSC RPC

{
  "error": "All BSC RPC servers unavailable"
}

Error Already enabled

The coin is already activated

{
  "error": "lp_coins:1308] Coin BUSD-BEP20 is already activated"
}

For enabling Z coins, refer to the ZHTLC activation tasks in the v2.0 Dev API.

To see more examples for other platforms like Fantom, Avalanche & Harmony, you can search the Komodo DeFi Framework API Coin Activation Commands List or build a single batch command to enable a set of selected coins via the Batch Coin Activation Form