Transferring crypto
The SDK allows you to transfer cryptocurrency from wallet to wallet using a CrypteriumTransferByWallet
class.
In this class, we have implemented several methods for conducting transferring operations:
-
The
fee
method is responsible for the fee when transferring crypto. -
The
limits
method returns the allowed minimum and maximum of the cryptocurrency a user can transfer. Limits are determined by the KYC level. -
Check the possibility of transferring using the
check
method. -
If the transferring with the given parameters is possible, run the
execute
method to confirm the transaction.
See more details in the description of each method.
CrypteriumTransferByWallet class
The CrypteriumTransferByWallet
class has been implemented to transfer cryptocurrency from wallet to wallet. To manage the process, initialize the CrypteriumTransferByWallet object:
let transfer: CrypteriumTransferByWallet = CrypteriumAPI.transferByWallet()
transfer: ICrypteriumTransferByWallet = CrypteriumAPI.transferByWallet()
Methods
fee
Use the fee
method to get the fee while transferring crypto from wallet to wallet. The fee is a decimal fraction of the amount of crypto for transferring. To get the total amount for transferring use this formula:
total amount = amount + amount * fee.
Fee example
amount = 100 tokens
fee = 0.02
totalAmount = 100 + 100 * 0.02 = 102 tokens
The method calls a completion closure and puts an object of CRPTTransferByWalletFeeResult
type as an argument of the closure.
transfer.fee(amount: Decimal, currency: CRPTCurrency, address: String, completion: (CRPTTransferByWalletFeeResult) -> Void)
enum CRPTTransferByWalletFeeResult {
case success(CRPTAmount)
case failure(CRPTError)
}
transfer.fee(amount: BigDecimal, currency: CRPTCurrency, address: String, completion: (CRPTTransferByWalletFeeResult) -> Unit)
sealed class CRPTTransferByWalletFeeResult {
data class success(val amount: CRPTAmount) : CRPTTransferByWalletFeeResult()
data class failure(val error: CRPTError) : CRPTTransferByWalletFeeResult()
}
Income parameters
parameter name | parameter type | description |
amount | Decimal | amount of crypto to transfer |
currency | CRPTCurrency | cryptocurrency to transfer |
address | String | recipient's wallet address |
CRPTTransferByWalletFeeResult
The CRPTTransferByWalletFeeResult
object value is attached to a success or a failure case:
case | varyable | variable type | description |
success | amount | CRPTAmount | total amount of cryptocurrency to spend for transferring operation |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
AUTHORIZATION | authorization error |
VALIDATION | coin is not in the list of available pairs |
BACKEND | backend error |
limits
The limits
method allows you to get minimum and maximum amount of crypto a user can transfer. The method calls a completion closure and puts an object of CRPTLimitsResult
type as an argument of the closure.
transfer.limits(for currency: CRPTCurrency, completion: (CRPTLimitsResult) -> Void)
enum CRPTLimitsResult {
case success(CRPTLimits)
case failure(CRPTError)
}
transfer.limits(currency: CRPTCurrency, completion: (CRPTLimitsResult) -> Unit)
sealed class CRPTLimitsResult {
data class success(val currency: CRPTLimits) : CRPTLimitsResult()
data class failure(val error: CRPTErrorResponse) : CRPTLimitsResult()
}
Income parameters
parameter name | parameter type | description |
currency | CRPTCurrency | cryptocurrency to transfer |
CRPTLimitsResult
The CRPTLimitsResult
object value is attached to success or failure case:
case | variable | variable type | description |
success | currency | CRPTLimits | limits for transferred crypto |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
AUTHORIZATION | authorization error |
VALIDATION | coin is not in the list of available pairs |
check
Use the check
method to check if a user can transfer cryptocurrency from wallet to wallet. The method calls a completion closure and puts an object of CRPTTransferByWalletCheckResult
type as an argument of the closure.
transfer.check(amount: Decimal, currency: CRPTCurrency, address: String, completion: (CRPTTransferByWalletCheckResult) -> Void)
enum CRPTTransferByWalletCheckResult {
case success()
case failure(CRPTError)
}
transfer.check(amount: BigDecimal, currency: CRPTCurrency, address: String, completion: (CRPTTransferByWalletCheckResult) -> Unit)
sealed class CRPTTransferByWalletCheckResult {
object success : CRPTTransferByWalletCheckResult()
data class failure(val error: CRPTError) : CRPTTransferByWalletCheckResult()
}
Income parameters
parameter name | parameter type | description |
amount | Decimal | amount of crypto to transfer |
currency | CRPTCurrency | cryptocurrency to transfer |
address | String | recipient's wallet address |
CRPTTransferByWalletCheckResult
The CRPTTransferByWalletCheckResult
object value is attached to success or failure case:
case | variable | variable type | description |
success | - | - | transaction has passed all checks and is ready for execution |
failure | error | CRPTError | error details |
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
AUTHORIZATION | authorization error |
VALIDATION | coin is not in the list of available tokens |
BACKEND | backend error |
MAINTENANCE | maintenance error |
UPDATE | update error |
LIMITS | exceeding transaction or card limits |
KYC0 | exceeding monthly limits, KYC0 verification required |
KYC1 | exceeding monthly limits, KYC1 verification required |
KYC2 | exceeding monthly limits, KYC2 verification required |
execute
The execute
method commits the crypto transferring transaction. It calls a completion closure and puts an object of CRPTExchangeExecuteResult
type as an argument of the closure.
transfer.execute(amount: Decimal, currency: CRPTCurrency, address: String, completion: (CRPTTransferByWalletExecuteResult) -> Void)
enum CRPTTransferByWalletExecuteResult {
case success(CRPTTransactionStatus)
case failure(CRPTError)
}
transfer.execute(amount: BigDecimal, currency: CRPTCurrency, address: String, completion: (CRPTTransferByWalletExecuteResult) -> Unit)
sealed class CRPTTransferByWalletExecuteResult {
data class success(val status: CRPTTransactionStatus) : CRPTTransferByWalletExecuteResult()
data class failure(val error: CRPTError) : CRPTTransferByWalletExecuteResult()
}
Income parameters
parameter name | parameter type | description |
amount | Decimal | amount of crypto to transfer |
currency | CRPTCurrency | cryptocurrency to transfer |
address | String | recipient's wallet address |
CRPTTransferByWalletExecuteResult
The CRPTTransferByWalletExecuteResult
object value is attached to a success or a failure case:
case | variable | variable type | description |
success | status | CRPTTransactionStatus | transaction status |
failure | error | CRPTError | error details |
CRPTTransactionStatus
The CRPTTransactionStatus object may have one of the values below:
value | description |
SUCCESS | transaction committed |
FAILURE | transaction failed |
CRPTError
The type
property of the CRPTError object may have one of the values below:
value | error description |
AUTHORIZATION | authorization failed |
VALIDATION | the coin is not in the list of available tokens |
BACKEND | backend error |
MAINTENANCE | maintenance error |
UPDATE | update error |
LIMITS | exceeding the transaction or card limits |
KYC0 | exceeding the monthly limits, KYC0 verification required |
KYC1 | exceeding the monthly limits, KYC1 verification required |
KYC2 | exceeding the monthly limits, KYC2 verification required |
Updated over 2 years ago