Skip to content

DECENTfoundation/DCoreSwift-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DCore SDK for Swift

Travis CI platforms Carthage compatible

Set of APIs for accessing the DCore Blockchain.
If you are looking for other platforms you can find info below.

Requirements

  • Xcode 10.2+
  • Swift 5.0+ (from version 3.0.0+), Swift 4.2 (for versions 2.X.X)
  • automake & libtool (for building library dependecies - openssl, secp256k1)

Supported Platforms

  • iOS 10.0+

Installation

Use homebrew for OSX to install prerequisites

$ brew install automake
$ brew install libtool

Tested with carthage version: 0.33.0

Add this to Cartfile

github "DECENTfoundation/DCoreSwift-SDK" ~> 3.0.0

and then use

$ carthage update --platform iOS

Link following frameworks from Carthage/Build/iOS folder to your app:

BigInt.framework
CryptoSwift.framework
DCoreKit.framework
RxSwift.framework
SipHash.framework
Starscream.framework
SwiftyJSON.framework

To link these frameworks to the app, please follow instructions specified in documentation of Carthage

Head over to your project's Build Settings and ensure your Framework Search Paths are set to:

$(PROJECT_DIR)/Carthage/Build/iOS

Usage

You can find developer documentation for latest release here.

Access api using rest (Get an account object)

import DCoreKit

let api = DCore.Sdk.create(forRest: "https://testnet-api.dcore.io/rpc")
let disposable = api.account.get(byName: "public-account-2").subscribe(onSuccess: { 
	account in

	print(account.id) 
})

Access api using socket (Transfer amount between accounts)

import DCoreKit

let creds = try? Credentials("1.2.19".dcore.chainObject!, wif: "5KfatbpE1zVdnHgFydT7Cg9hJmUVLN7vQXJkBbzGrNSND3uFmAa")
let api = DCore.Sdk.create(forWss: "wss://testnet-api.dcore.io")
let disposable = api.account.transfer(from: creds!, to: "1.2.20", amount: AssetAmount(1000000)).subscribe(onSuccess: { 
	confirmation in

	print(confirmation.blockNum) 
})

Official DCore SDKs for other platforms

References