Evercoin is a an instant-access cryptocurrency exchange. This Swift API enables you to easily integrate cryptocurrency exchange funtionality into your IOS app.
- Swift3 or higher
- API Key // contact support@evercoin.com to obtain your API key
Download a version of the Evercoin swift's framework from SwiftAPI
import XCTest
import Darwin
@testableimport EvercoinAPI
classEvercoinAPITests:XCTestCase{overridefunc setUp(){
super.setUp()
// Make sure to use test endpoint during development and testing.
//let defaults = UserDefaults.standard
//defaults.set("https://test.evercoin.com/", forKey: "evercoin.api.endpoint")
}overridefunc tearDown(){
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()}func testExample(){letAPI_KEY:String="Your API Key"; // contact support@evercoin.com to obtain yours
letversion:String="v1";
letdeposit:String="BTC";
letdestination:String="ETH";
letrefundMainAddress:String="n4MZ1KydkCEokrr8fVAcGSghsSMjHvNexo";
letdestinationMainAddress:String="0xb306e1D76E4C4bd6462F370d4551F842eB4fFcad";
letdepositAmount:String="1.0";
letevercoin:Evercoin=EvercoinFactory.create(config:EvercoinApiConfig(apiKey: API_KEY, version: version))letcoins:CoinsResponse= evercoin.getCoins()letdepositCoin= coins.getCoin(symbol: deposit);
letdestinationCoin= coins.getCoin(symbol: destination);
if(depositCoin !=nil && !(depositCoin?.fromAvailable)!){
//Exchanging from BTC is not currently available.
return;
}if(destinationCoin !=nil && !(destinationCoin?.toAvailable)!){
//Exchanging to ETH is not currently available.
return;
}letrefundValidateReponse= evercoin.validateAddress(coin: deposit, address: refundMainAddress)if(refundValidateReponse.isSuccess! && refundValidateReponse.isValid! ==false){
//Your BTC address is not valid.
return;
}letrefundAddress=Address(mainAddress: refundMainAddress);
letdestinationValidateReponse= evercoin.validateAddress(coin: destination, address: destinationMainAddress)if(destinationValidateReponse.isSuccess! && destinationValidateReponse.isValid! ==false){
//Your ETH address is not valid.
return;
}letdestinationAddress=Address(mainAddress: destinationMainAddress);
letpriceResponse= evercoin.getPrice(depositCoin: deposit, destinationCoin: destination, depositAmount:Double(depositAmount), destinationAmount:nil)if priceResponse.isSuccess ==true{letorderResponse= evercoin.createOrder(priceResponse: priceResponse, refundAddress: refundAddress, destinationAddress: destinationAddress)if orderResponse.isSuccess ==true{EvercoinAPI.logToConsole(msg:"You should deposit to this address: "+(orderResponse.depositAddress?.mainAddress)!)while(true){sleep(10)letstatusResponse:StatusResponse= evercoin.getStatus(orderId: orderResponse.orderId!)if(statusResponse.exchangeStatus?.statusId ==Status.awaitingDeposit.statusId){letdepositMainAddress= orderResponse.depositAddress?.mainAddress
varprintStr="Send "+ depositAmount +""
printStr = printStr + deposit +" to the "+ depositMainAddress!
EvercoinAPI.logToConsole(msg: printStr)}elseif(statusResponse.exchangeStatus?.statusId ==Status.awaitingConfirm.statusId){EvercoinAPI.logToConsole(msg:"Looks like you sent "+ deposit +". Waiting for confirmation on the blockchain.");
}elseif(statusResponse.exchangeStatus?.statusId ==Status.awaitingExchange.statusId){EvercoinAPI.logToConsole(msg:"Your "+ destination +" is on the way.");
}elseif(statusResponse.exchangeStatus?.statusId ==Status.allDone.statusId){EvercoinAPI.logToConsole(msg:"Success! Enjoy your "+ destination);
return;
}}}}}func testPerformanceExample(){
// This is an example of a performance test case.
self.measure{
// Put the code you want to measure the time of here.
}}}More information and API documentation can be found at https://evercoin.com/api/
Please contact support@evercoin.com