Komodo DeFi SDK RPC Protocol v2.0
Starting with version beta-2.1.3434, the Komodo DeFi SDK supports the standardized protocol format called mmrpc 2.0
.
It includes a uniform request, successful and error response formats. At the moment, only a few RPC methods support the mmrpc 2.0
protocol.
Structure | Type | Description |
---|---|---|
mmrpc | string | the string specifying the version of the Komodo DeFi SDK RPC protocol. Must be exactly "2.0" |
userpass | string (optional) | your password for protected RPC methods. Skip this field if the specified method is public |
method | string | the name of the method to be invoked |
params | object (optional) | a structured value that holds the parameter values to be used during the invocation of the method. This field may be omitted if the method doesn't take arguments |
id | number (optional) | the identifier is established by the client. Komodo DeFi SDK will reply with the same value in the Response object if the id field is included and not NULL |
Structure | Type | Description |
---|---|---|
mmrpc | string | the string specifying the version of the Komodo DeFi SDK RPC protocol |
result | object | the value of this field is determined by the method invoked on Komodo DeFi SDK |
id | number (optional) | the identifier established by the client. The same value as in the Request if it was passed |
Structure | Type | Description |
---|---|---|
mmrpc | string | the string specifying the version of the Komodo DeFi API RPC protocol |
error | string | the common error description |
error_path | string | the error path consisting of file names separated by a dot similar to JSON path notation |
error_trace | string | the error path consisting of file and line number pairs separated by ']' |
error_type | string | the string error identifier used to determine the cause of the error |
error_data | object | an object containing the error data of the corresponding error_type |
id | number (optional) | the identifier established by the client. The same value as in the Request if it was passed |
{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "withdraw",
"params": {
"coin": "KMD",
"to": "RJTYiYeJ8eVvJ53n2YbrVmxWNNMVZjDGLh",
"amount": "10"
},
"id": 0
}
{
"mmrpc": "2.0",
"result": {
"tx_hex": "0400008085202f8901ef25b1b7417fe7693097918ff90e90bba1351fff1f3a24cb51a9b45c5636e57e010000006b483045022100b05c870fcd149513d07b156e150a22e3e47fab4bb4776b5c2c1b9fc034a80b8f022038b1bf5b6dad923e4fb1c96e2c7345765ff09984de12bbb40b999b88b628c0f9012102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ffffffff0200e1f505000000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ac8cbaae5f010000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ace87a5e5d000000000000000000000000000000",
"tx_hash": "1ab3bc9308695960bc728fa427ac00d1812c4ae89aaa714c7618cb96d111be58",
"from": ["R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW"],
"to": ["R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW"],
"total_amount": "60.10253836",
"spent_by_me": "60.10253836",
"received_by_me": "60.00253836",
"my_balance_change": "-0.1",
"block_height": 0,
"timestamp": 1566472936,
"fee_details": {
"type": "Utxo",
"coin": "KMD",
"amount": "0.1"
},
"coin": "DOC",
"internal_id": ""
},
"id": 0
}
{
"mmrpc": "2.0",
"error": "The amount 0.000005 is too small",
"error_path": "utxo_common",
"error_trace": "utxo_common:1379] utxo_common:301]",
"error_type": "AmountIsTooSmall",
"error_data": {
"amount": "0.000005"
},
"id": 0
}
The available
balance is not sufficient to transfer the specified amount.
Structure | Type | Description |
---|---|---|
coin | string | the name of the coin which balance is not sufficient. This coin name may differ from the requested coin. For example, ERC20 fees are paid by ETH (gas) |
available | string (numeric) | the balance available for transfer |
required | string (numeric) | the amount required to transfer the specified amount. This amount is necessary but may not be sufficient |
{
"mmrpc": "2.0",
"error": "Not enough DOC to withdraw: available 69.75066225, required at least 1000.00001",
"error_path": "utxo_common",
"error_trace": "utxo_common:1379] utxo_common:449]",
"error_type": "NotSufficientBalance",
"error_data": {
"coin": "DOC",
"available": "69.75066225",
"required": "1000.00001"
},
"id": 0
}
The specified amount is too low. Required at least threshold
.
Structure | Type | Description |
---|---|---|
amount | string (numeric) | the amount the user was willing to transfer |
threshold | string (numeric) | the amount has not to be less than the threshold |
The specified to
address is not valid.
Structure | Type | Description |
---|---|---|
(none) | string | the error description |
The specified fee
is not valid.
Structure | Type | Description |
---|---|---|
(none) | string | the error description |
{
"mmrpc": "2.0",
"error": "Invalid fee policy: Expected 'UtxoFixed' or 'UtxoPerKbyte' fee types, found EthGas",
"error_path": "utxo_common",
"error_trace": "utxo_common:1371]",
"error_type": "InvalidFeePolicy",
"error_data": "Expected 'UtxoFixed' or 'UtxoPerKbyte' fee types, found EthGas",
"id": 0
}
{
"mmrpc": "2.0",
"error": "Invalid fee policy: Expected 'EthGas' fee type, found UtxoFixed",
"error_path": "eth",
"error_trace": "eth:535]",
"error_type": "InvalidFeePolicy",
"error_data": "Expected 'EthGas' fee type, found UtxoFixed",
"id": 0
}
The specified coin was not found or is not activated yet.
Structure | Type | Description |
---|---|---|
coin | string | the not found coin specified in the Request |
The request was failed due to a network error.
Structure | Type | Description |
---|---|---|
(none) | string | the transport error description |
The request was failed due to an Komodo DeFi API internal error.
Structure | Type | Description |
---|---|---|
(none) | string | the internal error description |
{
"mmrpc": "2.0",
"error": "BCH",
"error_path": "my_tx_history_v2.lp_coins",
"error_trace": "my_tx_history_v2:389] lp_coins:2847]",
"error_type": "CoinIsNotActive",
"error_data": "BCH",
"id": null
}
{
"mmrpc": "2.0",
"error": "BCH",
"error_path": "my_tx_history_v2",
"error_trace": "my_tx_history_v2:336]",
"error_type": "NotSupportedFor",
"error_data": "BCH",
"id": null
}
{
"mmrpc": "2.0",
"error": "Storage is not initialized for BCH",
"error_path": "my_tx_history_v2",
"error_trace": "my_tx_history_v2:343]",
"error_type": "StorageIsNotInitialized",
"error_data": "Storage is not initialized for BCH",
"id": null
}
{
"mmrpc": "2.0",
"error": "SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\"no such column: block_height\"))",
"error_path": "my_tx_history_v2.sql_tx_history_storage",
"error_trace": "my_tx_history_v2:351] sql_tx_history_storage:472]",
"error_type": "StorageError",
"error_data": "SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\"no such column: block_height\"))",
"id": null
}
There are some common objects that are used in the Komodo DeFi SDK RPC protocol. These standard objects have been collected and grouped into the following sections: