{"id":15172236,"url":"https://github.com/horizontalsystems/ethereum-kit-ios","last_synced_at":"2025-10-01T09:30:29.133Z","repository":{"id":37406091,"uuid":"151700054","full_name":"horizontalsystems/ethereum-kit-ios","owner":"horizontalsystems","description":"Comprehensive EVM SDK (Ethereum, Binance Smart Chain, Avalanche, Arbitrum, Optimism, Polygon) for iOS devices, implemented on Swift. Create wallets, watch wallets (read-only), sync transactions, filter transactions by type (erc20, bep20, swap transactions etc.), swap using native DEX protocols, connect to DeFi smart contracts using WalletConnect. Easily extendable to work with custom smart contracts. Full support for EIP1159.","archived":true,"fork":false,"pushed_at":"2022-09-30T05:32:20.000Z","size":10454,"stargazers_count":173,"open_issues_count":14,"forks_count":42,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-01-01T05:00:57.259Z","etag":null,"topics":["arbitrum","avalanche","avalanche-c-chain","bep20","binance-smart-chain","eip1159","erc-20","erc20","ethereum","ethereum-library","ethereum-sdk","ethereum-wallet","evm","matic","nft","optimism","polygon","solana","solana-sdk","web3"],"latest_commit_sha":null,"homepage":"https://unstoppable.money","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/horizontalsystems.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-05T09:41:39.000Z","updated_at":"2024-10-17T11:55:13.000Z","dependencies_parsed_at":"2022-07-13T01:10:27.089Z","dependency_job_id":null,"html_url":"https://github.com/horizontalsystems/ethereum-kit-ios","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horizontalsystems%2Fethereum-kit-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horizontalsystems%2Fethereum-kit-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horizontalsystems%2Fethereum-kit-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horizontalsystems%2Fethereum-kit-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/horizontalsystems","download_url":"https://codeload.github.com/horizontalsystems/ethereum-kit-ios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234845313,"owners_count":18895739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrum","avalanche","avalanche-c-chain","bep20","binance-smart-chain","eip1159","erc-20","erc20","ethereum","ethereum-library","ethereum-sdk","ethereum-wallet","evm","matic","nft","optimism","polygon","solana","solana-sdk","web3"],"created_at":"2024-09-27T09:42:53.803Z","updated_at":"2025-10-01T09:30:23.240Z","avatar_url":"https://github.com/horizontalsystems.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EthereumKit-iOS\n\nEthereumKit-iOS is a native(Swift), secure, reactive and extensible Ethereum client toolkit for iOS platform. It can be used by ETH/Erc20 wallet or by dapp client for any kind of interactions with Ethereum blockchain.\n\n## Features\n\n- Ethereum wallet support, including internal Ether transfer transactions\n- Support for ERC20 token standard\n- Uniswap DEX support\n- Reactive-functional API\n- Implementation of Ethereum's JSON-RPC client API over HTTP or WebSocket\n- Support for Infura\n- Support for Etherscan\n\n\n### EthereumKit.swift\n- Sync account state/balance\n- Sync/Send/Receive Ethereum transactions \n- Internal transactions retrieved from Etherscan\n- Reactive API for Smart Contracts (*Erc20Kit.swift* and *UniswapKit.swift* use *EthereumKit.swift* for interactions with the blockchain)\n- Reactive API for wallet\n- Restore with mnemonic phrase\n\n### Erc20Kit.swift\n- Sync balance\n- Sync/Send/Receive Erc20 token transactions\n- Allowance management\n- Incoming Erc20 token transactions retrieved from Etherscan\n- Reactive API for wallet\n\n### UniswapKit.swift\n\nSupports following settings:\n- Price Impact\n- Deadline\n- Recipient\n- Fee on Transfer\n\n## Usage\n\n\n### Initialization\n\nFirst you need to initialize an EthereumKit.Kit instance\n\n```swift\nimport EthereumKit\n\nlet ethereumKit = try! Kit.instance(\n        words: [\"word1\", ... , \"word12\"],\n        syncMode: .api,\n        networkType: .ropsten,\n        rpcApi: .infuraWebSocket(id: \"\", secret: \"\"),\n        etherscanApiKey: \"\",\n        walletId: \"walletId\",\n        minLogLevel: .error\n)\n```\n\n##### `syncMode` parameter\n\n- `.api`: Uses RPC\n- `.spv`: Ethereum light client. *Not supported currently*\n- `.geth`: Geth client. *Not supported currently*\n\n##### `networkfkType` parameter\n\n- `.mainNet`\n- `.ropsten`\n- `.kovan`\n\n##### `rpcApi` parameter\n\n- `.infuraWebSocket(id: \"\", secret: \"\")`: RPC over HTTP\n- `.infura(id: \"\", secret: \"\"\")`: RPC over WebSocket\n\n##### Additional parameters:\n- `minLogLevel`: Can be configured for debug purposes if required.\n\n### Starting and Stopping\n\n*EthereumKit.Kit* instance requires to be started with `start` command\n\n```swift\nethereumKit.start()\nethereumKit.stop()\n```\n\n### Getting wallet data\n\nYou can get account state, lastBlockHeight, syncState, transactionsSyncState and some others synchronously \n\n```swift\nguard let state = ethereumKit.accountState else {\n    return\n}\n\nstate.balance    // 2937096768\nstate.nonce      // 10\n\nethereumKit.lastBlockHeight  // 10000000\n```\n\nYou also can subscribe to Rx observables of those and some others\n\n```swift\nethereumKit.accountStateObservable.subscribe(onNext: { state in print(\"balance: \\(state.balance); nonce: \\(state.nonce)\") })\nethereumKit.lastBlockHeightObservable.subscribe(onNext: { height in print(height) })\nethereumKit.syncStateObservable.subscribe(onNext: { state in print(state) })\nethereumKit.transactionsSyncStateObservable.subscribe(onNext: { state in print(state) })\n\n// Subscribe to all Ethereum transactions synced by the kit\nethereumKit.allTransactionsObservable.subscribe(onNext: { transactions in print(transactions.count) })\n\n// Subscribe to Ether transactions\nethereumKit.etherTransactionsObservable.subscribe(onNext: { transactions in print(transactions.count) })\n```\n\n### Send Transaction\n\n```swift\nlet decimalAmount: Decimal = 0.1\nlet amount = BigUInt(decimalAmount.roundedString(decimal: decimal))!\nlet address = Address(hex: \"0x73eb56f175916bd17b97379c1fdb5af1b6a82c84\")!\n\nethereumKit\n        .sendSingle(address: address, value: amount, gasPrice: 50_000_000_000, gasLimit: 1_000_000_000_000)\n        .subscribe(onSuccess: { transaction in \n            print(transaction.transaction.hash.hex)  // sendSingle returns FullTransaction object which contains transaction, receiptWithLogs and internalTransactions\n        })\n```\n\n### Estimate Gas Limit\n\n```swift\nlet decimalAmount: Decimal = 0.1\nlet amount = BigUInt(decimalAmount.roundedString(decimal: decimal))!\nlet address = Address(hex: \"0x73eb56f175916bd17b97379c1fdb5af1b6a82c84\")!\n\nethereumKit\n        .estimateGas(to: address, amount: amount, gasPrice: 50_000_000_000)\n        .subscribe(onSuccess: { gasLimit in \n            print(gasLimit)\n        })\n```\n\n### Send Erc20 Transaction\n\n```swift\nimport EthereumKit\nimport Erc20Kit\n\nlet decimalAmount: Decimal = 0.1\nlet amount = BigUInt(decimalAmount.roundedString(decimal: decimal))!\nlet address = Address(hex: \"0x73eb56f175916bd17b97379c1fdb5af1b6a82c84\")!\n\nlet erc20Kit = Erc20Kit.Kit.instance(ethereumKit: ethereumKit, contractAddress: \"contract address of token\")\nlet transactionData = erc20Kit.transferTransactionData(to: address, value: amount)\n\nethereumKit\n        .sendSingle(transactionData: transactionData, gasPrice: 50_000_000_000, gasLimit: 1_000_000_000_000)\n        .subscribe(onSuccess: { [weak self] _ in})\n```\n\n### Send Uniswap swap transaction\n\n```swift\nimport EthereumKit\nimport UniswapKit\nimport Erc20Kit\n\nlet uniswapKit = UniswapKit.Kit.instance(ethereumKit: ethereumKit)\n\nlet tokenIn = uniswapKit.etherToken\nlet tokenOut = uniswapKit.token(try! Address(hex: \"0xad6d458402f60fd3bd25163575031acdce07538d\"), decimal: 18)\nlet amount: Decimal = 0.1\n\nuniswapKit\n        .swapDataSingle(tokenIn: tokenIn, tokenOut: tokenOut)\n        .flatMap { swapData in\n            let tradeData = try! uniswapKit.bestTradeExactIn(swapData: swapData, amountIn: amount)\n            let transactionData = try! uniswapKit.transactionData(tradeData: tradeData)\n            \n            return ethereumKit.sendSingle(transactionData: transactionData, gasPrice: 50_000_000_000, gasLimit: 1_000_000_000_000)\n        }\n        .subscribe(onSuccess: { [weak self] _ in})\n```\n\n## Extending\n\n### Add transaction syncer\n\nSome smart contracts store some information concerning your address, which you can't retrieve in a standard way over RPC. If you have an external API to get them from, you can create a custom syncer and add it to EthereumKit. It will sync all the transactions your syncer gives.\n\n[Erc20TransactionSyncer](https://github.com/horizontalsystems/ethereum-kit-ios/blob/master/Erc20Kit/Classes/Core/Erc20TransactionSyncer.swift) is a good example of this. It gets token transfer transactions from Etherscan and feeds EthereumKit syncer with them. It is added to EthereumKit as following:\n```swift\nlet transactionSyncer = Erc20TransactionSyncer(...)\nethereumKit.add(syncer: transactionSyncer)\n```\n\n### Smart contract call\n\nIn order to make a call to any smart contract, you can use `ethereumKit.sendSingle(transactionData:,gasPrice:,gasLimit:)` method. You need to create an instance of `TransactionData` object. Currently, we don't have an ABI or source code parser. Please, look in Erc20Kit.swift and UniswapKit.swift to see how `TransactionData` object is formed.\n\n\n## Prerequisites\n\n* Xcode 10.0+\n* Swift 5+\n* iOS 11+\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.5.0+ is required to build EthereumKit.\n\nTo integrate EthereumKit into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n  pod 'EthereumKit.swift'\n  pod 'Erc20.swift'\n  pod 'UniswapKit.swift'\nend\n```\n\nThen, run the following command:\n```bash\n$ pod install\n```\n\n\n## Example Project\n\nAll features of the library are used in example project. It can be referred as a starting point for usage of the library.\n\n* [Example Project](https://github.com/horizontalsystems/ethereum-kit-ios/tree/master/Example)\n\n## Dependencies\n\n* [HSHDWalletKit](https://github.com/horizontalsystems/hd-wallet-kit-ios) - HD Wallet related features, mnemonic phrase generation.\n* [OpenSslKit.swift](https://github.com/horizontalsystems/open-ssl-kit-ios) - Crypto functions required for working with blockchain.\n* [Secp256k1Kit.swift](https://github.com/horizontalsystems/secp256k1-kit-ios) - Crypto functions required for working with blockchain.\n* [HsToolKit.swift](https://github.com/horizontalsystems/hs-tool-kit-ios) - Helpers library from HorizontalSystems\n* RxSwift\n* BigInt\n* GRDB.swift\n* Starscream\n\n## License\n\nThe `EthereumKit-iOS` toolkit is open source and available under the terms of the [MIT License](https://github.com/horizontalsystems/ethereum-kit-ios/blob/master/LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorizontalsystems%2Fethereum-kit-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhorizontalsystems%2Fethereum-kit-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorizontalsystems%2Fethereum-kit-ios/lists"}