web3.js utility library written in Swift.
- Features
- Component Libraries
- Requirements
- Communication
- Installation
- Usage
- Intro - Create Account, Encoding, Signing Transaction
- Improvements
- FAQ
- Credits
- Contributors
- License
- Create Account
- Import Account
- Create and Encode Transaction
- Sign Transaction
-
More Features - WIP -
Complete Documentation
In order to keep web3swift focused specifically on core ethereum based utility functionality, additional component libraries will be created by the Radical App LLC to bring additional functionality to the mercury protocol ecosystem.
- iOS Example App - Example showcasing use of web3swift library.
- [Mercury Wallet - Wallet App to use with mercury protocol. (Coming Soon)
- iOS 9.0+
- Xcode 9.2+
- Swift 4.0.0+
- If you need help, use Stack Overflow. (Tag 'web3swift')
- If you'd like to ask a general question, use Stack Overflow.
- 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.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ sudo gem install cocoapods
CocoaPods 1.1+ is required to build web3swift 4.0+.
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', :git => 'https://github.com/MercuryProtocol/web3.swift.git', :branch => 'master'
end
Then, run the following command:
$ pod install
- In order to run project, you will have to turn off bitcode support as Geth doesn't support bitcode. Please check: golang/go#22395
- iOS simulator compilation can be fixed by removing arm7 support from valid architectures in the app. You can find more information here.
Create keystore and account with password.
let configuration = EthAccountConfiguration(namespace: "wallet", password: "qwerty")
let (keystore, _) = EthAccountCoordinator.default.launch(configuration)
If you don't want to create account, this can be achieved by passing nil
let configuration = EthAccountConfiguration(namespace: "wallet", password: nil)
let (keystore, _) = EthAccountCoordinator.default.launch(configuration)
var addressError: NSError? = nil
let amountToTransfer = 5
let gethToAccountAddress: GethAddress! = GethNewAddressFromHex("0x39db95b4f60bd75846c46df165d9e854b3cf2b56", &addressError)
guard let amount = GethBigInt.bigInt(amountToTransfer) else {
print("Invalid amount")
return
}
let transferFunction = EthFunction(name: "transfer", inputParameters: [toAccountAddress, amount])
let encodedTransferFunction = web3swift.encode(transferFunction)
let signedTransaction = web3swift.sign(address: contractAddress, encodedFunctionData: encodedTransferFunction, nonce: nonce, gasLimit: Constants.gasLimit, gasPrice: Constants.gasPrice)
web3swift is utility library written in swift which brings web3j encoding capabilities to Swift. Also, helps managements of account based on Geth.
web3swift is owned and maintained by the Radical App LLC. You can follow them on Twitter at @MercuryProtocol for project updates and releases.
If you do want to participate please follow the guideline.
If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to security@mercuryprotocol.com. Please do not post it to a public issue tracker.
web3swift is released under the MIT license. See LICENSE for details.