Skip to content
Official repository of the DCore SDK for Swift
Branch: master
Clone or download
fl3xman Merge pull request #19 from DECENTfoundation/feature/guard-private-ke…
…y-decode

Guard decoding Private Key from WIF when decoded WIF is too short
Latest commit 908345b May 24, 2019

README.md

DCore SDK for Swift

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

Carthage

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 --no-use-binaries

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

Furthermore, set your Header Search Paths to:

$(PROJECT_DIR)/Carthage/Checkouts/dcoreswift-sdk/Libraries/openssl/include
$(PROJECT_DIR)/Carthage/Checkouts/dcoreswift-sdk/Libraries/secp256k1/include

Usage

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

You can’t perform that action at this time.