/web3swift

Elegant Web3js functionality in Swift. Native ABI parsing and smart contract interactions.

Primary LanguageSwiftApache License 2.0Apache-2.0

matter-github-swift

web3swift

Version License Platform support Build Status

Ask questions

web3swift is your toolbelt for any kind interactions with Ethereum network.


Features

  • Swift implementation of web3.js functionality ⚡
  • Interaction with remote node via JSON RPC 💭
  • Smart-contract ABI parsing 📖
  • ABI deconding (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler)
  • RLP encoding
  • Interactions (read/write to Smart contracts) 🔄
  • Local keystore management (geth compatible)
  • Batched requests in concurrent mode
  • Literally following the standards:
    • BIP32 HD Wallets: Deterministic Wallet
    • BIP39 (Seed phrases)
    • BIP44 (Key generation prefixes)
    • EIP-155 (Replay attacks protection) enforced!
  • Comprehensive Unit and Integration Test Coverage
  • Complete Documentation

Design Decisions

  • Not every JSON RPC function is exposed yet, and 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

Requirements

  • iOS 9.0+ / macOS 10.11+
  • Xcode 9.0+
  • Swift 4.1+

Migration Guides

Communication

When using this lib, please make references to this repo and give your start! :) Nothing makes developers happier than seeing someone else use our work and go wild with it.

If you are using web3swift in your app or know of an app that uses it, please add it to this list.

Installation

CocoaPods

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

$ sudo gem install cocoapods

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target '<Your Target Name>' do
    use_frameworks!
    pod 'web3swift'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate web3swift into your Xcode project using Carthage, specify it in your Cartfile:

github "web3swift/web3swift" ~> 1.1.9

Run carthage update to build the framework and drag the built web3swift.framework into your Xcode project.

Example Project

You can try lib by running the example project:

  • Clone the repo: git clone https://github.com/matterinc/web3swift.git
  • Move to the repo: cd web3swift/Example/web3swiftExample
  • Install Dependencies: pod install
  • Open: open ./web3swiftExample.xcworkspace

Credits

Alex Vlasov, @shamatar, alex.m.vlasov@gmail.com

Petr Korolev, @skywinder

Security Disclosure

If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to Alex Vlasov alex.m.vlasov@gmail.com. Please do not post it to a public issue tracker.

Donations

The Matters are charged with open-sorсe and do not require money for using their web3swift lib. We want to continue to do everything we can to move the needle forward. If you use any of our libraries for work, see if your employers would be interested in donating. Any amount you can donate today to help us reach our goal would be greatly appreciated.

Our Ether wallet address: 0xe22b8979739d724343bd002f9f432f5990879901

Donate

License

web3swift is available under the Apache License 2.0 license. See the LICENSE for details.