WalletKit is a Swift custom built SDK on top of web3swift for creating, restoring multiaccount wallets, signing, sending transactions and getting account balance and much more
WalletKit is compatible with Swift Package Manager v5 (Swift 5 and above). Simply add it to the dependencies in your Package.swift
.
dependencies: [
.package(url: "https://github.com/awaiskhan1304/WalletSDK", from: "1.0.0")
.package(url: "https://github.com/web3swift-team/web3swift.git", exact: "3.1.2"),
]
Add then link the frameworks to the project build phases
- navigate to prohect build phases oprn link binary with libraries and drag drop WalletKitFramework and secp256k1
import WalletKitFramework
accountIndex - account to recover using recovery phrase i.e. multiple accounts with same recovery phrase
let address = Web3Wrapper.shared.createPrivateKey(password: "123", network: BlockchainNetworkType = .ethereum,words: [""],accountIndex: 0)
let accounts = Web3Wrapper.shared.getAccounts ()
Web3Wrapper.shared.removeAccount (account: String, removeAll: Bool = false)
let validated = Web3Wrapper.shared.validatePassword (account: String,password: String)
error in case there is error
let (txHash/signature,error) = Web3Wrapper.shared.performTransaction (_ type: TransactionType,_ fromAddress: String, chainId: Int,rpcUrl: String,password: String,toAddress: String = "",gasPrice: String = "",gasLimit: String = "",value: Double = 0.0, data: String = "")
let balance = Web3Wrapper.shared.getBalance (_ account: String,chainId: Int, rpcUrl: String)