Web3 and Geth wrapper utility in swift

What's New

Update Geth from 1.7.3 to 1.8.1


CocoaPods Compatible Platform Latest Tag Twitter

web3.js utility library written in Swift.

Table of contents


  • Create Account
  • Import Account
  • Create and Encode Transaction
  • Sign Transaction
  • More Features - WIP
  • Complete Documentation

Component Libraries

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
    pod 'web3swift', :git => 'https://github.com/MercuryProtocol/web3.swift.git', :branch => 'master'

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 Account

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)

Encoding Transaction

var addressError: NSError? = nil
let amountToTransfer = 5
let gethToAccountAddress: GethAddress! = GethNewAddressFromHex("0x39db95b4f60bd75846c46df165d9e854b3cf2b56", &addressError)
guard let amount = GethBigInt.bigInt(amountToTransfer) else {
    print("Invalid amount")
let transferFunction = EthFunction(name: "transfer", inputParameters: [toAccountAddress, amount])
let encodedTransferFunction = web3swift.encode(transferFunction)

Signing Transaction

let signedTransaction = web3swift.sign(address: contractAddress, encodedFunctionData: encodedTransferFunction, nonce: nonce, gasLimit: Constants.gasLimit, gasPrice: Constants.gasPrice)


What's web3swift?

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.

Security Disclosure

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.


  • Swift Tools
View More Packages from this Author


  • None
Last updated: Thu Nov 10 2022 10:25:33 GMT-0500 (GMT-05:00)