Swiftpack.co - Package - BANKEX/web3swift

You can ask for help in our Discord Channel

Support Stackoverflow Apps using web3swift

bkx-foundation-github-swift

Swift 4.2 Compatible Platforms iOS | macOS Compatible

web3swift

  • Swift implementation of web3.js functionality :zap:
  • Interaction with remote node via JSON RPC :thought_balloon:
  • Smart-contract ABI parsing :book:
  • Local keystore management (geth compatible)
  • Private key and transaction were created directly on an iOS device and sent directly to Infura node
  • Native API
  • Security (as cool as a hard wallet! Right out-of-the-box! :box: )
  • No unnecessary dependencies
  • Possibility to work with all existing smart contracts
  • Referencing the newest features introduced in Solidity

Features

  • Create Account
  • Import Account
  • Sign transactions
  • Send transactions, call functions of smart-contracts, estimate gas costs
  • Serialize and deserialize transactions and results to native Swift types
  • Convenience functions for chain state: block number, gas price
  • Check transaction results and get receipt
  • Parse event logs for transaction
  • Manage user's private keys through encrypted keystore abstractions
  • Batched requests in concurrent mode, checks balances of 580 tokens (from the latest MyEtherWallet repo) over 3 seconds
  • Literally following the standards:

BIP32 BIP39 BIP44 EIP 20 EIP 67 EIP 155 EIP 681 EIP 721 EIP 777 EIP 888

Requirements

Web3swift requires Swift 4.2 and deploys to macOS 10.10, iOS 9, watchOS 2 and tvOS 9 and linux.

Don't forget to set the iOS version in a Podfile, otherwise you get an error if the deployment target is less than the latest SDK.

Installation

  • Swift Package Manager: Although the Package Manager is still in its infancy, web3swift provides full support for it. Add this to the dependency section of your Package.swift manifest:

    .package(url: "https://github.com/BANKEX/web3swift.git", from: "2.1.0")
    
  • CocoaPods: Put this in your Podfile:

    pod 'web3swift.pod'
    
  • Carthage: Put this in your Cartfile:

    github "BANKEX/web3swift" ~> 2.1
    

Documentation

Hi. We spend a lot of time working on documentation. If you have some questions after reading it just open an issue or ask in our discord channel. We would be happy to help you.

Most of the classes are documented and have some examples on how to use it.

Read documentation in using Xcode

Github Pages

We would appreciate it if you translate our documentation into another language, and will be happy to provide you with all the necessary information on how to do this. We will compensate you for translations that will be included in the master branch.

Design decisions

  • Not every JSON RPC function is exposed yet, priority is given to the ones required for mobile devices
  • Functionality was focused on serializing and signing transactions locally on the device to send raw transactions to Ethereum network
  • Requirements for password input on every transaction are indeed a design decision. Interface designers can save user passwords with the user's consent
  • Public function for private key export is exposed for user convenience, but marked as UNSAFE_ :) Normal workflow takes care of EIP155 compatibility and proper clearing of private key data from memory

Contribution

For the latest version, please check develop branch.

Changes made to this branch will be merged into the master branch at some point.

Special thanks to

  • Gnosis team and their library Bivrost-swift for inspiration for the ABI decoding approach
  • Trust iOS Wallet for the collaboration and discussion of the initial idea
  • Official Ethereum and Solidity docs, everything was written from ground truth standards

Donate

Github

link
Stars: 395
Help us keep the lights on

Used By

Total: 1

Releases

2.1.3 - Dec 10, 2018

2.1.2 - Dec 7, 2018

2.1.1 - Dec 3, 2018

2.1 - Dec 3, 2018

Now we are using CommonCrypto instead of CryptoSwift Optimized mnemonics generation (10 times faster) Added PrivateKey and Signature classes

Performance

Operations per second in debug and release build mode

Before -> After

Encryption

HDNode:
 release x1.17      debug x3.38
 16670 -> 19666     1421 -> 4816
 
 HDNode-auth:
 release x6.0       debug x265
 133883 -> 809534   2334 -> 619319
 
 KeystoreV3:
 release            debug
 138 -> 141         1.28 -> 1.3013496
 
 BIP32Keystore:
 release x2.8       debug x2.2
 42 -> 120          0.63 -> 1.3975109
 
 Mnemonics generation:
 release x7.7       debug x7.2
 1455 -> 11252      1183 -> 8574
 
 Mnemonics to seed:
 release x11        debug x638
 61 -> 734          1.10 -> 702

KeystoreV3 and BIP32Keystore doesn't changed because they using scrypt do encrypt private key. We want to change all that in 2.2 update so BIP32Keystore will have HDNode performance and KeystoreV3 will have Generate Private key performance

PrivateKey class

Operations per second in debug and release build mode

 Generate Private key:
 release            debug
 175772             160180
 
 PrivateKey -> Public Key:
 release            debug
 26642              9036
 
 PrivateKey -> Address:
 release            debug
 11894              2058

2.0.9 - Nov 29, 2018

Added support for web3.js signatures Fixed v3 keystore private key Fixed SolidityDataReader.string() function