Skip to contents

Creates a new deposit address for a specified currency on KuCoin asynchronously by sending a POST request to the /api/v3/deposit-address/create endpoint. This internal function is designed for use within an R6 class and is not intended for direct end-user consumption.

Usage

add_deposit_address_v3_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  currency,
  chain = NULL,
  to = NULL,
  amount = NULL,
  .__coro_env_parent__ = <environment>
)

Arguments

keys

List containing API configuration parameters from get_api_keys(), including:

  • api_key: Character string; your KuCoin API key.

  • api_secret: Character string; your KuCoin API secret.

  • api_passphrase: Character string; your KuCoin API passphrase.

  • key_version: Character string; API key version (e.g., "2"). Defaults to get_api_keys().

base_url

Character string representing the base URL for the API. Defaults to get_base_url().

currency

Character string; the currency for which to create the deposit address (e.g., "BTC", "ETH", "USDT").

chain

Character string (optional); the chain identifier (e.g., "eth", "bech32", "btc"). If not provided, the API uses the default chain for the currency.

to

Character string (optional); the account type to deposit to ("main" or "trade"). If not provided, defaults to "main".

amount

Character string (optional); the deposit amount, only used for Lightning Network invoices.

Value

Promise resolving to a data.table containing the deposit address details, including:

  • address (character): The deposit address.

  • memo (character): Address remark (may be empty).

  • chainId (character): The chain identifier.

  • to (character): The account type.

  • expirationDate (integer): Expiration time (for Lightning Network).

  • currency (character): The currency.

  • chainName (character): The chain name.

Details

Workflow Overview

  1. URL Construction: Combines the base URL with the endpoint /api/v3/deposit-address/create.

  2. Request Body Preparation: Creates a list with required and optional parameters (currency, chain, to, amount), converted to JSON.

  3. Header Preparation: Generates authentication headers asynchronously via build_headers().

  4. API Request: Sends a POST request using httr::POST() with the constructed URL, headers, and JSON body, applying a 3-second timeout.

  5. Response Handling: Processes the JSON response with process_kucoin_response(), extracting the "data" field and converting it to a data.table.

API Endpoint

POST https://api.kucoin.com/api/v3/deposit-address/create

Usage

Utilised internally to create deposit addresses for various currencies, enabling deposits to the specified account type.

Official Documentation

KuCoin Add Deposit Address (V3)

Examples

if (FALSE) { # \dontrun{
keys <- get_api_keys()
base_url <- "https://api.kucoin.com"
main_async <- coro::async(function() {
  dt <- await(add_deposit_address_v3_impl(
    keys = keys,
    base_url = base_url,
    currency = "TON",
    chain = "ton",
    to = "trade"
  ))
  print(dt)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }