All Projects → skywinder → Web3swift

skywinder / Web3swift

Licence: apache-2.0
Elegant Web3js functionality in Swift. Native ABI parsing and smart contract interactions.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Web3swift

Eth Crypto
Cryptographic javascript-functions for ethereum and tutorials to use them with web3js and solidity
Stars: ✭ 420 (+77.22%)
Mutual labels:  ethereum, smart-contracts, dapp, web3, web3js
Blockchainbooks.github.io
Blockchain Books
Stars: ✭ 139 (-41.35%)
Mutual labels:  ethereum, smart-contracts, web3, web3js
React Ethereum Dapp Example
A starter boilerplate for an Ethereum dapp using web3.js v1.0, truffle, react, and parity
Stars: ✭ 384 (+62.03%)
Mutual labels:  ethereum, smart-contracts, web3, web3js
Erc20 Generator
Create an ERC20 Token for FREE in less than a minute with the most used Smart Contract Generator for ERC20 Token. No login. No setup. No coding required.
Stars: ✭ 202 (-14.77%)
Mutual labels:  ethereum, smart-contracts, dapp, web3js
Web3swift
Elegant Web3js functionality in Swift. Native ABI parsing and smart contract interactions on Ethereum network.
Stars: ✭ 462 (+94.94%)
Mutual labels:  json-rpc, ethereum, smart-contracts, web3
Celo Monorepo
Official repository for core projects comprising the Celo platform
Stars: ✭ 269 (+13.5%)
Mutual labels:  ethereum, smart-contracts, dapp, crypto
solidity-cli
Compile solidity-code faster, easier and more reliable
Stars: ✭ 49 (-79.32%)
Mutual labels:  dapp, smart-contracts, web3, web3js
Web3 By Example
Node.js with Web3 javascript examples for getting basic information (transactions, balances, network stats, and tokens) from the Ethereum blockchain.
Stars: ✭ 156 (-34.18%)
Mutual labels:  ethereum, web3, geth, web3js
Ethereumbook
Mastering Ethereum, by Andreas M. Antonopoulos, Gavin Wood
Stars: ✭ 11,663 (+4821.1%)
Mutual labels:  ethereum, smart-contracts, dapp, web3js
Eth.social
An Ethereum dApp for posting social events.
Stars: ✭ 17 (-92.83%)
Mutual labels:  ethereum, smart-contracts, dapp, web3
Web3.php
A php interface for interacting with the Ethereum blockchain and ecosystem. Native ABI parsing and smart contract interactions.
Stars: ✭ 507 (+113.92%)
Mutual labels:  ethereum, smart-contracts, web3, hacktoberfest
Starter Kit
An OpenZeppelin starter kit containing React, OpenZeppelin SDK & OpenZeppelin Contracts.
Stars: ✭ 101 (-57.38%)
Mutual labels:  ethereum, dapp, web3, web3js
Myetherapi
An API by MyEtherWallet. ETH / Ropsten / JSON RPC / Web3
Stars: ✭ 95 (-59.92%)
Mutual labels:  json-rpc, ethereum, web3, geth
Web3 Vs Ethers
A basic cheatsheet of Web3.js vs Ethers (along w/ example apps!)
Stars: ✭ 103 (-56.54%)
Mutual labels:  ethereum, dapp, web3, web3js
Awesome Solidity
A curated list of awesome Solidity resources
Stars: ✭ 111 (-53.16%)
Mutual labels:  ethereum, smart-contracts, dapp
Ergo
The Language for Smart Legal Contracts
Stars: ✭ 108 (-54.43%)
Mutual labels:  ethereum, smart-contracts, hacktoberfest
Web3x
Ethereum TypeScript Client Library - for perfect types and tiny builds.
Stars: ✭ 197 (-16.88%)
Mutual labels:  ethereum, web3, web3js
Ethvtx
🌀🛰 ethereum-ready & framework-agnostic redux store configuration
Stars: ✭ 125 (-47.26%)
Mutual labels:  ethereum, dapp, web3
Truffle
A tool for developing smart contracts. Crafted with the finest cacaos.
Stars: ✭ 11,909 (+4924.89%)
Mutual labels:  ethereum, smart-contracts, hacktoberfest
Metamask Mobile
Port of MetaMask Ethereum Ðapp browser for mobile devices (iOS only for now)
Stars: ✭ 119 (-49.79%)
Mutual labels:  ethereum, dapp, web3

web3swift

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

matter-github-swift Build Status Swift Platform CocoaPods Compatible Carthage Compatible License support Stackoverflow


Core features

  • [x] ⚡️ Swift implementation of web3.js functionality

  • [x] 💭 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] 🔄 Smart contracts interactions (read/write)

  • [x] ⛩ Infura support, patial Websockets API support

  • [x] ⚒ Parsing TxPool content into native values (ethereum addresses and transactions) - easy to get pending transactions

  • [x] 🖇 Event loops functionality

  • [x] 📱Supports Web3View functionality (WKWebView with injected "web3" provider)

  • [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)

    • [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] 🗜 Batched requests in concurrent mode

  • [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, '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. Create an empty Cartfile with the touch command and open it:

$ touch Cartfile
$ open -a Xcode Cartfile

Add the following line to the Cartfile and save it:

github "matter-labs/web3swift" "master"

Run carthage update to build the framework. By default, Carthage performs checkouts and creates a new directory 'Carthage' in the same location as your Cartfile. Open this directory, go to 'Build' directory, choose iOS or macOS directory, and use the selected directory framework in your Xcode project.

  • Swift Package Open xcode setting and add this repo as a source

Example usage

Send Ether
let value: String = "1.0" // In Ether
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let toAddress = EthereumAddress(toAddressString)!
let contract = web3.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
var options = TransactionOptions.defaultOptions
options.value = amount
options.from = walletAddress
options.gasPrice = .automatic
options.gasLimit = .automatic
let tx = contract.write(
    "fallback",
    parameters: [AnyObject](),
    extraData: Data(),
    transactionOptions: options)!
Send ERC-20 Token
let web3 = Web3.InfuraMainnetWeb3() 
let value: String = "1.0" // In Tokens
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let toAddress = EthereumAddress(toAddressString)!
let erc20ContractAddress = EthereumAddress(token.address)!
let contract = web3.contract(Web3.Utils.erc20ABI, at: erc20ContractAddress, abiVersion: 2)!
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
var options = TransactionOptions.defaultOptions
options.value = amount
options.from = walletAddress
options.gasPrice = .automatic
options.gasLimit = .automatic
let method = "transfer"
let tx = contract.write(
    method,
    parameters: [toAddress, amount] as [AnyObject],
    extraData: Data(),
    transactionOptions: options)!
Get account balance
let web3 = Web3.InfuraMainnetWeb3() 
let address = EthereumAddress("<Address>")!
let balance = try web3.eth.getBalance(address: address)
let balanceString = Web3.Utils.formatToEthereumUnits(balance, toUnits: .eth, decimals: 3)
Write Transaction and call smart contract method
let web3 = Web3.InfuraMainnetWeb3() 
let value: String = "0.0" // Any amount of Ether you need to send
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let contractMethod = "SOMECONTRACTMETHOD" // Contract method you want to write
let contractABI = "..." // Contract ABI
let contractAddress = EthereumAddress(contractAddressString)!
let abiVersion = 2 // Contract ABI version
let parameters: [AnyObject] = [...]() // Parameters for contract method
let extraData: Data = Data() // Extra data for contract method
let contract = web3.contract(contractABI, at: contractAddress, abiVersion: abiVersion)!
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
var options = TransactionOptions.defaultOptions
options.value = amount
options.from = walletAddress
options.gasPrice = .automatic
options.gasLimit = .automatic
let tx = contract.write(
    contractMethod,
    parameters: parameters,
    extraData: extraData,
    transactionOptions: options)!

Web3View example

You can see how to our demo project: WKWebView with injected "web3" provider:

git clone https://github.com/matter-labs/web3swift.git
cd web3swift/Example/web3swiftBrowser
pod install
open ./web3swiftBrowser.xcworkspace

Build from source

  • Clone repo
  • Instal dependencies via ./carthage-build.sh --platform iOS (temp workaround, foe of Carthage bug. For details please look at

Requirements

  • iOS 9.0+ / macOS 10.11+
  • Xcode 10.2+
  • Swift 5.0+

Migration Guides

Documentation

For full documentation details and FAQ, please look at Documentation

If you need to find or understand an API, check Usage.md.

FAQ moved Documentation Page

Here are quick references for essential features:

Projects that are using web3swift

If you are using this library in your project, please add a link to this repo.

Nothing makes developers happier than seeing someone else use our work and go wild with it.

Support

Contribute

Want to improve? It's awesome:

Then good news for you: We are ready to pay for your contribution via @gitcoin bot!

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 much appreciated.

Matter Labs are charged with open-sourс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.

Future steps

You are more than welcome to participate! Your contribution will be paid via @gitcoin Grant program.

  • [ ] L2 support (such as ZkSync)

  • [ ] Modularity with the basic Web3 subspec/SPM (the most basic functions like transaction signing and interacting with an http rpc server) and other modules with additional functionality

  • [ ] Complete Documentation (https://web3swift.github.io/web3swift)

  • [ ] Performance Improvements

  • [ ] Convenient methods for namespaces

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 the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].