jaumevn / neo-swift

Swift Wrapper for Neo Blockchain API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

neo-swift

Swift SDK for the NEO blockchain.

What is neo-swift

  • A swift client for interacting with a node on the NEO blockchain.
  • Written in Swift4 and using Xcode9 Beta
  • Primarily meant to be the SDK for iOS and macOS wallet software.
  • Underlying cryptographic methods compiled into frameworks via go-mobile.
  • iOS framework
  • underlying go code

Current Status

  • Implements read operations of neo blockchain
  • Allows for send asset transactions
  • This is pre-alpha software meant only to be used by experienced developers, use at your own risk

Supported Methods

    enum RPCMethod: String {
        case getBestBlockHash = "getbestblockhash"
        case getBlock = "getblock"
        case getBlockCount = "getblockcount"
        case getBlockHash = "getblockhash"
        case getConnectionCount = "getconnectioncount"
        case getTransaction = "getrawtransaction"
        case getTransactionOutput = "gettxout"
        case getUnconfirmedTransactions = "getrawmempool"
        case sendTransaction = "sendrawtransaction"
        //The following routes can't be invoked by calling an RPC server
        //We must use the wrapper for the nodes made by COZ
        case getBalance = "getbalance"
    }

Things in the pipleine

  • NEP2 Support
  • Other transaction types
  • Better management of dependencies
  • Carthage, Cocoapods, and SPM support
  • Improved Node/Network Selection
  • Improved Documentation

Quick Start

Clone the repo and open the project in xcode and run all tests in NeoSwiftTests.swift

Example Usage

func demo() {
  // Create an account via a wif string
  let wifPersonA = "L4Ns4Uh4WegsHxgDG49hohAYxuhj41hhxG6owjjTWg95GSrRRbLL" // REMINDER TO NEVER USE THIS FOR REAL FUNDS
  let wifPersonB = "L4sSGSGh15dtocMMSYS115fhZEVN9UuETWDjgGKu2JDu59yncyVf" // REMINDER TO NEVER USE THIS FOR REAL FUNDS
  let accountA = Account(wif: wifPersonA)
  let accountB = Account(wif: wifPersonB)
  print(accountA.wif)
  print(accountA.publicKeyString)
  print(accountA.privateKeyString)
  print(accountA.address)
  print(accountA.hashedSignature) //Data

  accountA.sendAssetTransaction(asset: .gasAssetId, amount: 1, toAddress: accountB.address) { success, error in
            assert(success ?? false)
  }
}

Dynamic framework

If you are linking NeoSwift as a Dynamic framework. Create a new “Run Script Phase” in your app’s target’s “Build Phases” and paste the following snippet in the script text field:

bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/NeoSwift.framework/strip-frameworks.sh"

This step is required to work around an App Store submission bug when archiving universal binaries.

Help

  • Open a new issue for any problems.
  • Send a message to @andreit1 on the NEO Slack.
  • If there's a feature you'd like to see included feel free to drop me a line or submit a pull request

License

About

Swift Wrapper for Neo Blockchain API

License:MIT License


Languages

Language:Swift 92.4%Language:Objective-C 3.7%Language:Shell 3.3%Language:C 0.7%