# withdraw

The withdraw method generates, signs, and returns a transaction that transfers the amount of coin to the address indicated in the to argument.

This method generates a raw transaction which should then be broadcast using send_raw_transaction.

# Arguments

Structure Type Description
coin string the name of the coin the user desires to withdraw
to string coins are withdrawn to this address
amount string (numeric) the amount the user desires to withdraw, ignored when max=true
memo string Optional. Adds a transaction memo for compatible coins (e.g. Tendermint ecosystem).
max bool withdraw the maximum available amount
fee.type string type of transaction fee; possible values: UtxoFixed, UtxoPerKbyte, EthGas
fee.amount string (numeric) fee amount in coin units, used only when type is UtxoFixed (fixed amount not depending on tx size) or UtxoPerKbyte (amount per Kbyte)
fee.gas_price string (numeric) used only when fee type is EthGas; sets the gas price in gwei units
fee.gas number (integer) used only when fee type is EthGas; sets the gas limit for transaction

# Response

Structure Type Description
from array of strings coins are withdrawn from this address; the array contains a single element, but transactions may be sent from several addresses (UTXO coins)
to array of strings coins are withdrawn to this address; this may contain the my_address address, where change from UTXO coins is sent
my_balance_change string (numeric) the expected balance of change in my_address after the transaction broadcasts
received_by_me string (numeric) the amount of coins received by my_address after the transaction broadcasts; the value may be above zero when the transaction requires that the Komodo DeFi Framework send change to my_address
spent_by_me string (numeric) the amount of coins spent by my_address; this value differ from the request amount, as the transaction fee is added here
total_amount string (numeric) the total amount of coins transferred
fee_details object the fee details of the generated transaction; this value differs for utxo and ETH/ERC20 coins, check the examples for more details
tx_hash string the hash of the generated transaction
tx_hex string transaction bytes in hexadecimal format; use this value as input for the send_raw_transaction method
coin string the name of the coin the user wants to withdraw
kmd_rewards object (optional) an object containing information about accrued rewards; always exists if the coin is KMD
kmd_rewards.amount string (numeric, optional) the amount of accrued rewards
kmd_rewards.claimed_by_me bool (optional) whether the rewards been claimed by me

# ⚠️ Error types

# NotSufficientBalance

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

# ZeroBalanceToWithdrawMax

The available balance is zero.

Structure Type Description
(none)

# AmountTooLow

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

# InvalidAddress

The specified to address is not valid.

Structure Type Description
(none) string the error description

# InvalidFeePolicy

The specified fee is not valid.

Structure Type Description
(none) string the error description

# NoSuchCoin

The specified coin was not found or is not activated yet.

Structure Type Description
coin string the not found coin specified in the Request

# Transport

The request was failed due to a network error.

Structure Type Description
(none) string the transport error description

# InternalError

The request was failed due to an Komodo DeFi Framework internal error.

Structure Type Description
(none) string the internal error description

# 📌 Examples

# Command (BTC, KMD, and other BTC-based forks)

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"mmrpc\":\"2.0\",\"method\":\"withdraw\",\"params\":{\"coin\":\"KMD\",\"to\":\"RJTYiYeJ8eVvJ53n2YbrVmxWNNMVZjDGLh\",\"amount\":\"10\"},\"id\":0}"

# Command (BTC, KMD, and other BTC-based forks, fixed fee)

curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\":{
    \"coin\": \"RICK\",
    \"to\":\"R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW\",
    \"amount\":\"1.0\",
    \"fee\": {
      \"type\":\"UtxoFixed\",
      \"amount\":\"0.1\"
    }
  },
  \"id\":0
}"

# Command (BTC, KMD, and other BTC-based forks, 1 RICK per Kbyte)

curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\":{
    \"coin\":\"RICK\",
    \"to\":\"R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW\",
    \"amount\":\"1.0\",
    \"fee\": {
      \"type\":\"UtxoPerKbyte\",
      \"amount\":\"1\"
    }
  },
  \"id\":0
}"

# Command (ETH, ERC20, and other ETH-based forks)

curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\": {
    \"coin\": \"ETH\",
    \"to\": \"0xbab36286672fbdc7b250804bf6d14be0df69fa28\",
    \"amount\": 10
  },
  \"id\": 0
}"

# Command (ETH, ERC20, and other ETH-based forks, with gas fee)

curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\": {
    \"coin\": \"COIN_NAME\",
    \"to\": \"RECIPIENT_ADDRESS\",
    \"amount\": \"AMOUNT\",
    \"fee\": {
      \"type\": \"EthGas\",
      \"gas_price\": \"3.5\",
      \"gas\": 55000
    }
  },
  \"id\":0
}"

# Command (max = true)

curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\": {
    \"coin\": \"ETH\",
    \"to\": \"0xbab36286672fbdc7b250804bf6d14be0df69fa28\",
    \"max\": true
  },
  \"id\": 0
}"
# Command (QRC20)
curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\": {
    \"coin\":\"QRC20\",
    \"to\":\"qHmJ3KA6ZAjR9wGjpFASn4gtUSeFAqdZgs\",
    \"amount\":10
  },
  \"id\":0
}"
# Command (QRC20, with gas fee)
curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\": {
    \"coin\": \"QRC20\",
    \"to\": \"qHmJ3KA6ZAjR9wGjpFASn4gtUSeFAqdZgs\",
    \"amount\": 10,
    \"fee\": {
      \"type\": \"Qrc20Gas\",
      \"gas_limit\": 250000,
      \"gas_price\": 40
    }
  },
  \"id\":0
}"
# Command (COSMOS, with memo)
curl --url "http://127.0.0.1:7783" --data "{
  \"mmrpc\": \"2.0\",
  \"userpass\": \"$userpass\",
  \"method\": \"withdraw\",
  \"params\": {
    \"coin\": \"IRIS\",
    \"to\": \"iaa16drqvl3u8sukfsu4lm3qsk28jr3fahja9vsv6k\",
    \"amount\": 13,
    \"memo\": \"It was a bright cold day in April, and the clocks were striking thirteen.\"
  },
  \"id\":0
}"