Code Monkey home page Code Monkey logo

web3swift's Introduction

bkx-foundation-github-swift

Important notices

With the version 0.3.0 API should be less volatile. All public functions should return a Result<>[https://github.com/antitypical/Result] instead of nil or throwing.

Example is not yet updated for 0.3.0, please use tests as an example for your code.

web3swift

Version License Platform

  • Swift implementation of web3.js functionality โšก
  • Interaction with remote node via JSON RPC ๐Ÿ’ญ
  • Smart-contract ABI parsing ๐Ÿ“–
    • ABI deconding
    • RLP encoding
  • Interactions (read/write to Smart contracts) ๐Ÿ”„
  • Local keystore management (geth compatible)
  • Literally following the standarts:
    • BIP32 HD Wallets: Deterministic Wallet
    • BIP39 (Seed phrases)
    • BIP44 (Key generation prefixes)
    • EIP-155 (Replay attacks protection) enforced!

Check this out

  • Private key and transaction were created directly on the iOS device and sent directly to Infura node
  • Native API
  • Security (as cool as hard wallet! Right out-of-the-box! :box: )

Design decisions

  • Not every JSON RPC function is exposed yet, priority is gives to ones required for mobile devices
  • Functionality was focused on serializing and signing transactions locally on device to send raw transaction to Ethereum network
  • Requirements for password input on every transactions are indeed a design decision. Interface designers can save user passwords given 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

Here it is

https://rinkeby.etherscan.io/tx/0xc6eca60ecac004a1501a4323a10edb7fa4cd1a0896675f6b51704c84dedad056

Transaction
Nonce: 35
Gas price: 5000000000
Gas limit: 21000
To: 0x6394b37Cf80A7358b38068f0CA4760ad49983a1B
Value: 1000000000000000
Data: 0x
v: 43
r: 73059897783840535708732471549376620878882680550447969052675399628060606060727
s: 12280625377431973240236065453692843538037349746280474092545114784968542260859
Intrinsic chainID: Optional(4)
Infered chainID: Optional(4)
sender: Optional(web3swift.EthereumAddress(_address: "0x855adf524273c14b7260a188af0ae30e82e91959"))

["id": 1514485925, "result": 0xc6eca60ecac004a1501a4323a10edb7fa4cd1a0896675f6b51704c84dedad056, "jsonrpc": 2.0]
On Rinkeby TXid = 0xc6eca60ecac004a1501a4323a10edb7fa4cd1a0896675f6b51704c84dedad056

Example

You can try it by yourself by running the example project:

  • Clone the repo
  • cd Example/web3swiftExample
  • run pod install from the Example/web3swiftExample directory.
  • open ./web3swiftExample.xcworkspace

Requirements

Web3swift requires Swift 4.0 and iOS 9.0 or macOS 10.13 although we recommend to use the latest iOS and MacOS versions for your own safety.

Installation

web3swift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'web3swift', git: 'https://github.com/Vaultie/web3swift.git'

Current functionality

  • 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

Global plans

  • Full reference web3js functionality
  • Light Ethereum subprotocol (LES) integration

Special thanks to

  • Gnosis team and their library Bivrost-swift for inspiration for the ABI decoding approach
  • Trust iOS Wallet for collaboration and discussion for initial idea

Contribution

For the latest version, please check develop branch. Changes from this branch will be merged into the master branch at some point.

Appreciation

When using this pod references to this repo, Bankex and Bankex Foundation are appreciated.

Authors

Alex Vlasov, @shamatar, [email protected]

Petr Korolev, @skywinder, [email protected]

License

web3swift is available under the Apache License 2.0 license. See the LICENSE file for more info.

web3swift's People

Contributors

skywinder avatar dsemenovsky avatar 6epreu avatar shamatar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.