enable_eth_with_tokens

The Komodo DeFi Framework supports ETH(Ethereum) and many other EVM type platform coins like AVAX(Avalanche), BNB(Binance), FTM(Fantom), MATIC(Polygon), ONE(Harmony), ETH-ARB20(Arbitrum). Additionally, it supports ERC20 tokens on the ETH chain and associated ERC20 like tokens on the rest of the platform coin chains.Using this method, you can enable a platform coin along with multiple ERC20 like tokens of the platform coin chain in a single command.

Request Parameters

Parameter Type Required Default Description
ticker string Ticker of the platform protocol coin. Options: ETH, AVAX, BNB, FTM, MATIC, ONE, ETH-ARB20
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
swap_contract_address string Address of etomic swap smart contract
fallback_swap_contract string Address of backup etomic swap smart contract.
nodes array of objects A list of standard CoinNode objects.
erc20_tokens_requests array of objects A list of standard TokensRequest objects.
gas_station_decimals integer 8 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" 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.
get_balances boolean true If false, coin and token balances will not be returned in the response, and the response will be returned more quickly.
priv_key_policy object {"type": "ContextPrivKey"} A standard PrivKeyPolicy object.
required_confirmations integer 3 When the platform coin is involved, the 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.
rpc_mode string Default Value can be Metamask only when the Komodo DeFi Framework is built targeting wasm.
tx_history boolean false 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
nft_req object Encapsulates the request parameters for NFT activation, including NFT provider configuration. A standard NftProvider object.
swap_v2_contracts object Must be provided if "use_trading_proto_v2" is true in your configuration. A standard SwapV2Contracts object.

Response Parameters

Parameter Type Required Description
current_block integer Block height of the coin being activated
eth_addresses_infos object A standard AddressInfo object. Note: the structure may vary based on the value of the get_balances parameter.
erc20_addresses_infos object A standard AddressInfo object. Note: the structure may vary based on the value of the get_balances parameter.
nfts_infos list A list of standard NftInfoBasic objects.

📌 Examples

Request including optional gas station parameters

POST enable_eth_with_tokens
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable_eth_with_tokens",
  "mmrpc": "2.0",
  "params": {
    "ticker": "ETH",
    "gas_station_url": "https://ethgasstation.info/json/ethgasAPI.json",
    "gas_station_decimals": 8,
    "gas_station_policy": {
      "policy": "MeanAverageFast"
    },
    "mm2": 1,
    "priv_key_policy": {
      "type": "ContextPrivKey"
    },
    "swap_contract_address": "0x24ABE4c71FC658C91313b6552cd40cD808b3Ea80",
    "fallback_swap_contract": "0x8500AFc0bc5214728082163326C2FF0C73f4a871",
    "nodes": [
      {
        "url": "https://eth3.cipig.net:18555",
        "ws_url": "wss://eth3.cipig.net:38555"
      },
      {
        "url": "https://node.komodo.earth:8080/ethereum",
        "komodo_proxy": true
      },
      {
        "url": "https://eth.drpc.org",
        "ws_url": "wss://eth.drpc.org"
      }
    ],
    "tx_history": true,
    "erc20_tokens_requests": [
      {
        "ticker": "APE-ERC20",
        "required_confirmations": 4
      },
      {
        "ticker": "BCH-ERC20",
        "required_confirmations": 4
      },
      {
        "ticker": "MINDS-ERC20",
        "required_confirmations": 4
      },
      {
        "ticker": "BUSD-ERC20",
        "required_confirmations": 4
      }
    ],
    "required_confirmations": 5,
    "requires_notarization": false
  }
}
Show Response

Response

{
  "mmrpc": "2.0",
  "result": {
      "current_block": 20590537,
      "eth_addresses_infos": {
          "0x083C32B38e8050473f6999e22f670d1404235592": {
              "derivation_method": {
                  "type": "Iguana"
              },
              "pubkey": "04ec603f83519cc2150bd99ed0ed6b3f7f029dedff2957cd22542e2504e3d2a7953c084f907cce2f0e26fb0cfc55e06925bf0f88a92b904224dba8ebafdf98ce7b",
              "balances": {
                  "spendable": "0",
                  "unspendable": "0"
              }
          }
      },
      "erc20_addresses_infos": {
          "0x083C32B38e8050473f6999e22f670d1404235592": {
              "derivation_method": {
                  "type": "Iguana"
              },
              "pubkey": "04ec603f83519cc2150bd99ed0ed6b3f7f029dedff2957cd22542e2504e3d2a7953c084f907cce2f0e26fb0cfc55e06925bf0f88a92b904224dba8ebafdf98ce7b",
              "balances": {
                  "BUSD-ERC20": {
                      "spendable": "0",
                      "unspendable": "0"
                  },
                  "MINDS-ERC20": {
                      "spendable": "0",
                      "unspendable": "0"
                  },
                  "APE-ERC20": {
                      "spendable": "0",
                      "unspendable": "0"
                  },
                  "BCH-ERC20": {
                      "spendable": "0",
                      "unspendable": "0"
                  }
              }
          }
      },
      "nfts_infos": {}
  },
  "id": null
}

Request with get_balances set to false

POST enable_eth_with_tokens
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable_eth_with_tokens",
  "mmrpc": "2.0",
  "params": {
    "ticker": "MATIC",
    "get_balances": false,
    "tx_history": false,
    "gas_station_url": "https://gasstation-mainnet.matic.network/",
    "swap_contract_address": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "fallback_swap_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "swap_v2_contracts": {
      "maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
      "taker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
      "nft_maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE"
    },
    "nodes": [
      {
        "url": "https://node.komodo.earth:8080/polygon",
        "komodo_proxy": true
      },
      {
        "url": "https://pol3.cipig.net:18755",
        "ws_url": "wss://pol3.cipig.net:38755"
      },
      {
        "url": "https://polygon-bor-rpc.publicnode.com",
        "ws_url": "wss://polygon-bor-rpc.publicnode.com"
      }
    ],
    "erc20_tokens_requests": [
      {
        "ticker": "PGX-PLG20",
        "required_confirmations": 4
      },
      {
        "ticker": "AAVE-PLG20",
        "required_confirmations": 4
      }
    ],
    "required_confirmations": 5,
    "requires_notarization": false
  }
}
Show Response

Response

{
    "mmrpc": "2.0",
    "result": {
        "current_block": 60937035,
        "eth_addresses_infos": {
            "0x083C32B38e8050473f6999e22f670d1404235592": {
                "derivation_method": {
                    "type": "Iguana"
                },
                "pubkey": "04ec603f83519cc2150bd99ed0ed6b3f7f029dedff2957cd22542e2504e3d2a7953c084f907cce2f0e26fb0cfc55e06925bf0f88a92b904224dba8ebafdf98ce7b"
            }
        },
        "erc20_addresses_infos": {
            "0x083C32B38e8050473f6999e22f670d1404235592": {
                "derivation_method": {
                    "type": "Iguana"
                },
                "pubkey": "04ec603f83519cc2150bd99ed0ed6b3f7f029dedff2957cd22542e2504e3d2a7953c084f907cce2f0e26fb0cfc55e06925bf0f88a92b904224dba8ebafdf98ce7b",
                "tickers": [
                    "PGX-PLG20",
                    "AAVE-PLG20"
                ]
            }
        },
        "nfts_infos": {}
    },
    "id": null
}

Request including NFT initialization

POST enable_eth_with_tokens
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable_eth_with_tokens",
  "mmrpc": "2.0",
  "params": {
    "ticker": "MATIC",
    "get_balances": false,
    "tx_history": false,
    "nft_req": {
      "type": "Moralis",
      "info": {
        "url": "https://moralis-proxy.komodo.earth"
      }
    },
    "gas_station_url": "https://gasstation-mainnet.matic.network/",
    "swap_contract_address": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "fallback_swap_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
    "nodes": [
      {
        "url": "https://node.komodo.earth:8080/polygon",
        "komodo_proxy": true
      },
      {
        "url": "https://pol3.cipig.net:18755",
        "ws_url": "wss://pol3.cipig.net:38755"
      },
      {
        "url": "https://polygon-bor-rpc.publicnode.com",
        "ws_url": "wss://polygon-bor-rpc.publicnode.com"
      }
    ],
    "erc20_tokens_requests": [
      {
        "ticker": "PGX-PLG20",
        "required_confirmations": 4
      },
      {
        "ticker": "AAVE-PLG20",
        "required_confirmations": 4
      }
    ],
    "required_confirmations": 5,
    "requires_notarization": false
  }
}
Show Response

Response

{
  "mmrpc": "2.0",
  "result": {
      "current_block": 61329162,
      "eth_addresses_infos": {
          "0x083C32B38e8050473f6999e22f670d1404235592": {
              "derivation_method": {
                  "type": "Iguana"
              },
              "pubkey": "04d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2a91c9ce32b6fc5489c49e33b688423b655177168afee1b128be9b2fee67e3f3b"
          }
      },
      "erc20_addresses_infos": {
          "0x083C32B38e8050473f6999e22f670d1404235592": {
              "derivation_method": {
                  "type": "Iguana"
              },
              "pubkey": "04d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2a91c9ce32b6fc5489c49e33b688423b655177168afee1b128be9b2fee67e3f3b",
              "tickers": [
                  "PGX-PLG20",
                  "AAVE-PLG20"
              ]
          }
      },
      "nfts_infos": {
          "0x73a5299824cd955af6377b56f5762dc3ca4cc078,1": {
              "token_address": "0x73a5299824cd955af6377b56f5762dc3ca4cc078",
              "token_id": "1",
              "chain": "POLYGON",
              "contract_type": "ERC721",
              "amount": "1"
          },
          "0x3987dfed574927e7a3309758ccf949ad2403fcbb,1": {
              "token_address": "0x3987dfed574927e7a3309758ccf949ad2403fcbb",
              "token_id": "1",
              "chain": "POLYGON",
              "contract_type": "ERC1155",
              "amount": "1"
          }
      }
  },
  "id": null
}

Request using WalletConnect

Prior to coin activation using WalletConnect, you need to establish a connection with wc_new_connection

POST enable_eth_with_tokens
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "enable_eth_with_tokens",
  "mmrpc": "2.0",
  "params": {
    "ticker": "ETH",
    "gas_station_url": "https://ethgasstation.info/json/ethgasAPI.json",
    "gas_station_decimals": 8,
    "gas_station_policy": {
      "policy": "MeanAverageFast"
    },
    "mm2": 1,
    "rpc_mode": "Default",
    "priv_key_policy": {
      "type": "WalletConnect",
      "data": "3569914dd09a5cc4ac92dedab354f06ff5db17ef616233a8ba562cbea51269fd"
    },
    "swap_contract_address": "0x24ABE4c71FC658C91313b6552cd40cD808b3Ea80",
    "fallback_swap_contract": "0x8500AFc0bc5214728082163326C2FF0C73f4a871",
    "nodes": [
      {
        "url": "https://eth3.cipig.net:18555",
        "ws_url": "wss://eth3.cipig.net:38555"
      },
      {
        "url": "https://node.komodo.earth:8080/ethereum",
        "komodo_proxy": true
      },
      {
        "url": "https://ethereum-rpc.publicnode.com",
        "ws_url": "wss://ethereum-rpc.publicnode.com"
      }
    ],
    "tx_history": true,
    "erc20_tokens_requests": [
      {
        "ticker": "PEPE-ERC20",
        "required_confirmations": 4
      }
    ],
    "required_confirmations": 5
  }
}
Show Response

Response

Error Responses

Show Errors

Error Types

StructureTypeDescription
CoinProtocolParseErrorstringParsing the protocol of the platform coin you are trying to activate failed
InternalErrorstringThe request was failed due to an Komodo DeFi Framework API internal error
PlatformCoinCreationErrorstringThere was an error when trying to activate the platform coin
PlatformConfigIsNotFoundstringConfig of the platform coin you are trying to activate is not found
PlatformIsAlreadyActivatedstringThe platform coin you are trying to activate is already activated
PrivKeyNotAllowedstringThe privkey is not allowed
TokenConfigIsNotFoundstringConfig of the token you are trying to activate is not found
TokenProtocolParseErrorstringParsing the protocol of the token you are trying to activate failed
TransportstringThe request was failed due to a network error
UnexpectedDerivationMethodstringThe derivation method used is unexpected
UnexpectedPlatformProtocolstringUnexpected platform protocol found for the platform coin you are trying to activate
UnexpectedTokenProtocolstringUnexpected protocol is found in the config of the token you are trying to activate

PlatformIsAlreadyActivated Error

In this case, you need to disable the platform coin and try again.

{
    "mmrpc": "2.0",
    "error": "ETH",
    "error_path": "platform_coin_with_tokens",
    "error_trace": "platform_coin_with_tokens:297]",
    "error_type": "PlatformIsAlreadyActivated",
    "error_data": "ETH",
    "id": null
}

PlatformConfigIsNotFound Error

{
    "mmrpc": "2.0",
    "error": "Platform ETH config is not found",
    "error_path": "platform_coin_with_tokens.prelude",
    "error_trace": "platform_coin_with_tokens:302] prelude:79]",
    "error_type": "PlatformConfigIsNotFound",
    "error_data": "ETH",
    "id": null
}

CoinProtocolParseError Error

{
    "mmrpc": "2.0",
    "error": "Platform coin ETH protocol parsing failed: invalid type: null, expected adjacently tagged enum CoinProtocol",
    "error_path": "platform_coin_with_tokens.prelude",
    "error_trace": "platform_coin_with_tokens:302] prelude:82]",
    "error_type": "CoinProtocolParseError",
    "error_data": {
        "ticker": "ETH",
        "error": "invalid type: null, expected adjacently tagged enum CoinProtocol"
    },
    "id": null
}

UnexpectedPlatformProtocol Error

{
    "mmrpc": "2.0",
    "error": "Unexpected platform protocol QTUM for ETH",
    "error_path": "platform_coin_with_tokens.prelude.eth_with_token_activation",
    "error_trace": "platform_coin_with_tokens:302] prelude:90] eth_with_token_activation:64]",
    "error_type": "UnexpectedPlatformProtocol",
    "error_data": { "ticker": "ETH", "protocol": { "type": "QTUM" } },
    "id": null
}

TokenConfigIsNotFound Error

{
    "mmrpc": "2.0",
    "error": "Token BTUSD-ERC20 config is not found",
    "error_path": "platform_coin_with_tokens.prelude",
    "error_trace": "platform_coin_with_tokens:314] platform_coin_with_tokens:109] prelude:79]",
    "error_type": "TokenConfigIsNotFound",
    "error_data": "BTUSD-ERC20",
    "id": null
}

TokenProtocolParseError Error

{
    "mmrpc": "2.0",
    "error": "Token BUSD-ERC20 protocol parsing failed: unknown variant `TERC20`, expected one of `UTXO`, `QTUM`, `QRC20`, `ETH`, `ERC20`, `TENDERMINT`, `TENDERMINTTOKEN`, `LIGHTNING`, `SOLANA`, `SPLTOKEN`, `ZHTLC`",
    "error_path": "platform_coin_with_tokens.prelude",
    "error_trace": "platform_coin_with_tokens:314] platform_coin_with_tokens:109] prelude:82]",
    "error_type": "TokenProtocolParseError",
    "error_data": {
        "ticker": "BUSD-ERC20",
        "error": "unknown variant `TERC20`, expected one of `UTXO`, `QTUM`, `QRC20`, `ETH`, `ERC20`, `TENDERMINT`, `TENDERMINTTOKEN`, `LIGHTNING`, `SOLANA`, `SPLTOKEN`, `ZHTLC`"
    },
    "id": null
}

UnexpectedTokenProtocol Error

{
    "mmrpc": "2.0",
    "error": "Unexpected token protocol QRC20 { platform: \"ETH\", contract_address: \"0x4Fabb145d64652a948d72533023f6E7A623C7C53\" } for BUSD-ERC20",
    "error_path": "platform_coin_with_tokens.prelude.erc20_token_activation",
    "error_trace": "platform_coin_with_tokens:314] platform_coin_with_tokens:109] prelude:90] erc20_token_activation:58]",
    "error_type": "UnexpectedTokenProtocol",
    "error_data": {
        "ticker": "BUSD-ERC20",
        "protocol": {
            "type": "QRC20",
            "protocol_data": {
                "platform": "ETH",
                "contract_address": "0x4Fabb145d64652a948d72533023f6E7A623C7C53"
            }
        }
    },
    "id": null
}

InvalidRequest Error

Returned when the rpc_mode parameter is set to Metamask but the Komodo DeFi Framework was not built targeting wasm.

{
    "mmrpc": "2.0",
    "error": "Error parsing request: unknown variant `Metamask`, expected `Default`",
    "error_path": "dispatcher",
    "error_trace": "dispatcher:118]",
    "error_type": "InvalidRequest",
    "error_data": "unknown variant `Metamask`, expected `Default`",
    "id": null
}

Transport Error

Returned when coin nodes are unresponsive.

{
    "mmrpc": "2.0",
    "error": "Failed to get client version for all nodes",
    "error_path": "platform_coin_with_tokens.mod",
    "error_trace": "platform_coin_with_tokens:454] mod:717]",
    "error_type": "Transport",
    "error_data": "Failed to get client version for all nodes",
    "id": null
}