Add Deposit Address (V3) (Implementation)
Source:R/impl_account_deposit.R
add_deposit_address_v3_impl.Rd
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 toget_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
URL Construction: Combines the base URL with the endpoint
/api/v3/deposit-address/create
.Request Body Preparation: Creates a list with required and optional parameters (
currency
,chain
,to
,amount
), converted to JSON.Header Preparation: Generates authentication headers asynchronously via
build_headers()
.API Request: Sends a POST request using
httr::POST()
with the constructed URL, headers, and JSON body, applying a 3-second timeout.Response Handling: Processes the JSON response with
process_kucoin_response()
, extracting the"data"
field and converting it to adata.table
.
Usage
Utilised internally to create deposit addresses for various currencies, enabling deposits to the specified account type.
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()
} # }