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 nameparameter typedescription
amountDecimalamount of crypto to transfer
currencyCRPTCurrencycryptocurrency to transfer
addressStringrecipient's wallet address

CRPTTransferByWalletFeeResult

The CRPTTransferByWalletFeeResult object value is attached to a success or a failure case:

casevaryablevariable typedescription
successamountCRPTAmounttotal amount of cryptocurrency to spend for transferring operation
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin is not in the list of available pairs
BACKENDbackend 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 nameparameter typedescription
currencyCRPTCurrencycryptocurrency to transfer

CRPTLimitsResult

The CRPTLimitsResult object value is attached to success or failure case:

casevariablevariable typedescription
successcurrencyCRPTLimitslimits for transferred crypto
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin 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 nameparameter typedescription
amountDecimalamount of crypto to transfer
currencyCRPTCurrencycryptocurrency to transfer
addressStringrecipient's wallet address

CRPTTransferByWalletCheckResult

The CRPTTransferByWalletCheckResult object value is attached to success or failure case:

casevariablevariable typedescription
success--transaction has passed all checks and is ready for execution
failureerrorCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization error
VALIDATIONcoin is not in the list of available tokens
BACKENDbackend error
MAINTENANCEmaintenance error
UPDATEupdate error
LIMITSexceeding transaction or card limits
KYC0exceeding monthly limits, KYC0 verification required
KYC1exceeding monthly limits, KYC1 verification required
KYC2exceeding 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 nameparameter typedescription
amountDecimalamount of crypto to transfer
currencyCRPTCurrencycryptocurrency to transfer
addressStringrecipient's wallet address

CRPTTransferByWalletExecuteResult

The CRPTTransferByWalletExecuteResult object value is attached to a success or a failure case:

casevariablevariable typedescription
successstatusCRPTTransactionStatustransaction status
failureerrorCRPTErrorerror details

CRPTTransactionStatus

The CRPTTransactionStatus object may have one of the values below:

valuedescription
SUCCESStransaction committed
FAILUREtransaction failed

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization failed
VALIDATIONthe coin is not in the list of available tokens
BACKENDbackend error
MAINTENANCEmaintenance error
UPDATEupdate error
LIMITSexceeding the transaction or card limits
KYC0exceeding the monthly limits, KYC0 verification required
KYC1exceeding the monthly limits, KYC1 verification required
KYC2exceeding the monthly limits, KYC2 verification required