Popularity
7.6
Stable
Activity
5.9
Declining
818
21
439

Description

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

Programming language: Swift
License: Apache License 2.0
Tags: Blockchain     Web3     Etherium    
Latest version: v2.6.5

web3swift-matterlabs alternatives and similar libraries

Based on the "Blockchain" category.
Alternatively, view web3swift alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of web3swift-matterlabs or a related project?

Add another 'Blockchain' Library

README

web3swift

web3swift is an iOS toolbelt for interaction with the Ethereum network.

Social medias

Join our discord or Telegram if you need a support or want to contribute to web3swift development!

matter-github-swift Web3swift CI Swift Platform CocoaPods Compatible Carthage Compatible License support Stackoverflow


<!-- MarkdownTOC -->

<!-- /MarkdownTOC -->

Core features

  • [x] :zap: Swift implementation of web3.js functionality
  • [x] :thought_balloon: Interaction with remote node via JSON RPC
  • [x] 🔐 Local keystore management (geth compatible)
  • [x] 🤖 Smart-contract ABI parsing
  • [x] 🔓ABI deconding (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler)
  • [x] 🕸Ethereum Name Service (ENS) support - a secure & decentralised way to address resources both on and off the blockchain using simple, human-readable names
  • [x] :arrows_counterclockwise: Smart contracts interactions (read/write)
  • [x] ⛩ Infura support
  • [x] ⚒ Parsing TxPool content into native values (ethereum addresses and transactions) - easy to get pending transactions
  • [x] 🖇 Event loops functionality
  • [x] 🕵️‍♂️ Possibility to add or remove "middleware" that intercepts, modifies and even cancel transaction workflow on stages "before assembly", "after assembly"and "before submission"
  • [x] ✅Literally following the standards (BIP, EIP, etc):
    • [x] BIP32 (HD Wallets), BIP39 (Seed phrases), BIP44 (Key generation prefixes)
  • [x] EIP-20 (Standart interface for tokens - ERC-20), EIP-67 (Standard URI scheme), EIP-155 (Replay attacks protection), EIP-2718 (Typed Transaction Envelope), EIP-1559 (Gas Fee market change)
    • [x] And many others (For details about this EIP's look at Documentation page): EIP-681, EIP-721, EIP-165, EIP-777, EIP-820, EIP-888, EIP-1400, EIP-1410, EIP-1594, EIP-1643, EIP-1644, EIP-1633, EIP-721, EIP-1155, EIP-1376, ST-20
  • [x] RLP encoding
  • [x] Base58 encoding scheme
  • [x] Formatting to and from Ethereum Units
  • [x] Comprehensive Unit and Integration Test Coverage

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, '13.0'

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

Then, run the following command:

$ pod install

Swift Package

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/skywinder/web3swift.git", .upToNextMajor(from: "3.0.0"))
]

Example usage

In the imports section:

import web3swift
import Core

Send Ether

let transaction: CodableTransaction = .emptyTransaction
transaction.from = from ?? transaction.sender // `sender` one is if you have private key of your wallet address, so public key e.g. your wallet address could be infereted
transaction.value = value
transaction.gasLimitPolicy = .manual(78423)
transaction.gasPricePolicy = .manual(20000000000)
web3.eth.send(transaction)

Contract read method

let contract = web3.contract(Web3.Utils.erc20ABI, at: receipt.contractAddress!)!
let readOp = contract.createReadOperation("name")!
readOp.transaction.from = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")
let response = try await readTX.callContractMethod()

Write Transaction and call smart contract method

let abiString = "[]" // some ABI string
let bytecode = Data.fromHex("") // some ABI bite sequence
let contract = web3.contract(abiString, at: nil, abiVersion: 2)!
let parameters = [...] as [AnyObject]
let deployOp = contract.prepareDeploy(bytecode: bytecode, constructor: contract.contract.constructor, parameters: parameters)!
deployOp.transaction.from = "" // your address
deployOp.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")

Sending network request to a node

func feeHistory(blockCount: UInt, block: BlockNumber, percentiles:[Double]) async throws -> Web3.Oracle.FeeHistory {
    let requestCall: APIRequest = .feeHistory(blockCount, block, percentiles)
    let response: APIResponse<Web3.Oracle.FeeHistory> = try await APIRequest.sendRequest(with: web3.provider, for: requestCall) /// explicitly declaring `Result` type is **required**.
    return response.result
}

Build from source

SPM

git clone https://github.com/skywinder/web3swift.git
cd web3swift
swift build

Requirements

  • iOS 13.0 / macOS 10.15
  • Xcode 12.5
  • Swift 5.5

Documentation

Documentation is under construction👷🏻👷🏼‍♀️. We’re trying our best to comment all public API as detailed as we can, but the end it still far to come. But in one of the nearest minor updates we’ll bring DocC support of already done amount of docs. And your PR in such are more than welcome.

Projects that are using web3swift

Please take a look at Our costumers wiki page.

Support

Join our discord and Telegram if you need a support or want to contribute to web3swift development!

Contribute

Want to improve? It's awesome: Then good news for you: We are ready to pay for your contribution via @gitcoin bot!

Contribution

  1. You are more than welcome to participate and get bounty by contributing! Your contribution will be paid via @gitcoin Grant program.
  2. Find or create an issue
  3. You can find open bounties in Gitcoin Bounties list
  4. Commita fix or a new feature in branch, push your changes
  5. Submit a pull request to develop branch
    1. Please, provide detailed description to it to help us proceed it faster.

@skywinder are charged with open-sourсe and do not require money for using web3swift library. We want to continue to do everything we can to move the needle forward.

Credits

Security Disclosure

If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.

License

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


*Note that all licence references and agreements mentioned in the web3swift-matterlabs README section above are relevant to that project's source code only.