No description or website provided.
Clone or download
Latest commit f5ce708 Nov 12, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Clean Pods folder Oct 19, 2018
NANJFrameworks SDK - fix check min amount. Sep 28, 2018
.gitignore Update .gitignore Oct 19, 2018
.travis.yml Re change folder project. Jul 13, 2018
LICENSE Re change folder project. Jul 13, 2018
NANJFrameworks.podspec Update readme and pod spec Jul 31, 2018
README.md Update README.md Nov 12, 2018
_Pods.xcodeproj Re change folder project. Jul 13, 2018

README.md

NANJ SDK PROJECT

CODE NAME: FIERCE TIGER

Discord

## Features
  • Create NANJ Wallet
  • Import NANJ Wallet via Private Key / Key Store
  • Export Private Key/ Key Store from NANJ Wallet
  • Transfer NANJ Coin
  • Transaction History
  • Get NANJCOIN Rate in JPY
  • Capture Wallet Address via QRCode
  • Capture Wallet Address via NFC Tapping
  • Get minimum allowed amount on transfer for specific ERC20 Token
  • Get maximum transaction fee on transfer for specific ERC20 Token
  • 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, support@nanjcoin.com

License

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