Latest 1.1.0
Homepage https://github.com/NANJ-COIN/ios-sdk
License MIT
Platforms ios 10.0
Authors

SwiftDate


Discord

Features

  • [x] Create NANJ Wallet
  • [x] Import NANJ Wallet via Private Key / Key Store
  • [x] Export Private Key/ Key Store from NANJ Wallet
  • [x] Transfer NANJ Coin
  • [x] Transaction History
  • [x] Get NANJCOIN Rate in JPY
  • [x] Capture Wallet Address via QRCode
  • [x] Capture Wallet Address via NFC Tapping
  • [x] Get minimum allowed amount on transfer for specific ERC20 Token
  • [x] Get maximum transaction fee on transfer for specific ERC20 Token
  • [x] Get NANJCOIN rate in USD

Requirements

  • iOS 10.0+
  • Xcode 9.3+
  • Swift 3.1+

Communication

  • If you need help or ask a general question, use
    Discord Chat
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate NANJFrameworks into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'NANJFrameworks'
end

Then, run the following command:

$ pod install

Usage

Initialization

  • In AppDelegate.swift , import NANJFrameworks
    import NANJFrameworks
  • Add following lines to didFinishLaunchingWithOptions method
//Set Development Mode
NANJWalletManager.shared.setDevelopmentMode(isDevelopment: true)
NANJWalletManager.shared.startConfig(appId: "AppId", appSecret: "AppSecret", coinName: "CoinName")

Environment Setup

Development mode with staging server

NANJWalletManager.shared.setDevelopmentMode(isDevelopment: true)

Production mode with production server

NANJWalletManager.shared.setDevelopmentMode(isDevelopment: false)

Notes: Please call the method before startConfig

Create new Wallet

To create new wallet, use CreateWallet method via shared instance of NANJWalletManager

NANJWalletManager.shared.createWallet(password:"Password")

To receive event of successful wallet creation, assign delegate in NANJWalletManager

NANJWalletManager.shared.delegate = self

Once wallet creating, the delegate will call via method:

func didCreatingWallet(wallet: NANJWallet?)

Once wallet created, the delegate will call via method

func didCreateWallet(wallet: NANJWallet?, error: Error?) {

Import wallet

  • With Private key
    NANJWalletManager.shared.importWallet(privateKey: "Private Key")
  • With Key store (Bear in mind that we will need password to unlock keystore)
    NANJWalletManager.shared.importWallet(keyStore "Key Store", password "Password")

If wallet is imported successfully, the delegate will be invoked via method

func didImportWallet(wallet: NANJWallet?, error: Error?)

Return wallet if successful import,
error if there is an error.

Export Wallet

  • Export private key
NANJWalletManager.shared.exportPrivateKey(wallet: "NANJWallet")

Private key will be received via a method of delegate

func didExportPrivatekey(wallet: NANJWallet, privateKey: String?, error: Error?, error: nil)

return String privateKey if successful export.

And Error if there is a error.

  • Export keystore
    NANJWalletManager.shared.exportKeystore(wallet: "NANJWallet", password: "Password")

    Similar to export private key, export keystore will return over delegate with method

    func didExportKeystore(wallet: NANJWallet, keyStore: String?, error: Error?)

Transfer NANJCOIN

In order to send NANJ Coin to a specific address, Use NANJWallet instance to send like lines of code below

self.currentWallet = NANJWalletManager.shared.getCurrentWallet()
self.currentWallet?.delegate = self
self.currentWallet?.sendNANJ(toAddress: "NANJ Address", amount: "Amount send")

Outcome of sending NANJCoin will be confirmed over delegate with method

func didSendNANJCompleted(transaction: NANJTransaction?)

Or error persist via

func didSendNANJError(error: String?)

Get NANJCOIN Rate in JPY

self.currentWallet?.delegate = self
self.currentWallet?.getNANJRate()

NANJ rate will be returned over delegate method

@objc optional func didGetNANJRate(rate: Double)

Get NANJCOIN Rate in JPY or USD

self.walletManager.delegate = self
self.walletManager.getNANJRateWith(currency: string)

Currency symbol for input the method getNANJRateWith

US Dollar : 'usd' and JPY : 'jpy'

NANJ rate will be returned over delegate method

@objc optional func didGetNANJCurrencyRate(rate: Double, currency: String)

Get transaction list

self.currentWallet?.delegate = self
self.currentWallet?.getTransactionList(page: 1, offset: 20)

Receive via delegate call

func didGetTransactionList(transactions: Array<NANJTransaction>?)

NANJTransaction Class

public class NANJTransaction: NSObject {
public let id: UInt?
public let txHash: String?
public let status: Int?
public let from: String?
public let to: String?
public let value: String?
public let message: String?
public let txFee: String?
public let timestamp: UInt?
public let tokenSymbol: String?
...
}

Get minimum amount, max transaction fee per transfer

After set current ERC20 token. SDK can get minimum amount and maximum transaction fee. This minimum amount and maximum fee will be for chosen ERC20 token.

Get minimum amount per transfer

NANJWalletManager.shared.getMinimumAmount()

Get maximum fee per transfer

NANJWalletManager.shared.getMaxFee()

NANJ SDK Support mutiple ERC20/ERC223

To retreive supported ERC20/ERC223

let arrayOfERC20 = NANJWalletManager.shared.getListERC20Support()

To retreive supported ERC20/ERC223 by Identifier of ERC20

let idERC20 = 1
let arrayOfERC20 = NANJWalletManager.shared.getERC20Support(idERC20)

To use ERC20/ERC223

let idERC20 = 1
NANJWalletManager.shared.setCurrentERC20Support(idERC20)

To retrieve current ERC20/ERC223

NANJWalletManager.shared.getCurrentERC20Support(idERC20)

This feature allows the SDK can switch among multiple ERC20/ERC223 coins

Author

NANJCOIN, [email protected]

License

please read our license at this link. LICENSE
you can change Language JP/EN

Latest podspec

{
    "name": "NANJFrameworks",
    "version": "1.1.0",
    "summary": "NANJCOIN SDK",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/NANJ-COIN/ios-sdk",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "NANJ": "[email protected]"
    },
    "source": {
        "git": "https://github.com/NANJ-COIN/ios-sdk.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "NANJFrameworks/Classes/**/*",
    "default_subspecs": "NANJSubSpec",
    "subspecs": [
        {
            "name": "NANJSubSpec",
            "dependencies": {
                "BigInt": [
                    "~> 3.0"
                ],
                "TrustCore": [
                    "~> 0.0.6"
                ],
                "TrustKeystore": [
                    "~> 0.4.0"
                ],
                "CryptoSwift": [],
                "JSONRPCKit": [],
                "KeychainSwift": [],
                "APIKit": []
            }
        }
    ]
}

Pin It on Pinterest

Share This