HDWalletKit is a Swift framwork that enables you to create and use bitcoin HD wallet (Hierarchical Deterministic Wallets) in your own app.
You can check if the address generation is working right [here](https://iancoleman.io/bip39/).- HD and NonHD wallets support
- Mnemonic recovery phrease in BIP39
- Keystore generation
- Read keystore file
- Sign ether transaction
- ERC20 Tokens
- Sign UTXO based transaction
To integrate HDWalletKit into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'HDWalletKit'To install with Carthage, simply add this in your Cartfile:
github"essentiaone/HDWallet"- 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.
letentropy=Data(hex:"000102030405060708090a0b0c0d0e0f")letmnemonic=Mnemonic.create(entropy: entropy)print(mnemonic)
// abandon amount liar amount expire adjust cage candy arch gather drum buyer
letseed=Mnemonic.createSeed(mnemonic: mnemonic)print(seed.toHexString())letmnemonic=Mnemonic.create()letseed=Mnemonic.createSeed(mnemonic: mnemonic)letprivateKey=PrivateKey(seed: seed, coin:.bitcoin)
// BIP44 key derivation
// m/44'
letpurpose= privateKey.derived(at:.hardened(44))
// m/44'/0'
letcoinType= purpose.derived(at:.hardened(0))
// m/44'/0'/0'
letaccount= coinType.derived(at:.hardened(0))
// m/44'/0'/0'/0
letchange= account.derived(at:.notHardened(0))
// m/44'/0'/0'/0/0
letfirstPrivateKey= change.derived(at:.notHardened(0))print(firstPrivateKey.publicKey.address)letdata="abandon amount liar amount expire adjust cage candy arch gather drum buyer"letkeystore=try!KeystoreV3(data: data, password:"qwertyui")letencodedKeystoreDaya=(try? keystore?.encodedData())letkeystore=try!KeystoreV3(data: encodedKeystoreDaya, password: password)guardlet decoded =try? keystore?.getDecriptedKeyStore(password: password)else{fatalError()}print(decoded)letmnemonic=Mnemonic.create()letseed=Mnemonic.createSeed(mnemonic: mnemonic)letnetwork:Network=.main(.bitcoin)letwallet=Wallet(seed: seed, network: network)letaccount= wallet.generateAccount()print(account)letsigner=EIP155Signer()letrawTransaction1=EthereumRawTransaction(
value:Wei("10000000000000000")!,
to:"0x34205555576717bBdF8158E2b2c9ed64EB1e6B85",
gasPrice:99000000000,
gasLimit:21000,
nonce:2)guardlet signed =try? signer.hash(rawTransaction: rawTransaction1).toHexString()else{return}print(signed)For getting UTXO you can use (https://github.com/essentiaone/essentia-bridges-api-ios)
letaddress=tryLegacyAddress("1HLqrFX5fYwKriU7LRKMQGhwpz5HuszjnK", coin:.bitcoin)letutxoWallet=UTXOWallet(privateKey:"Kz9UKkL6bKE92QPxQbPcqkCZTnCyLVyfRNFRSbToNjyb4bx321fh")letsignedTx=try utxoWallet.createTransaction(to: address, amount:0, utxos: utxos)leterc20Token=ERC20(contractAddress:"0x8f0921f30555624143d427b340b1156914882c10", decimal:18, symbol:"ESS")letaddress="0x2f5059f64D5C0c4895092D26CDDacC58751e0C3C"letdata=try! erc20Token.generateDataParameter(toAddress: address, amount:"3")leterc20Token=ERC20(contractAddress:"0x8f0921f30555624143d427b340b1156914882c10", decimal:18, symbol:"ESS")letdata=try! erc20Token.generateGetBalanceParameter(toAddress:"2f5059f64D5C0c4895092D26CDDacC58751e0C3C")letprivateKey=PrivateKey(pk:"L35qaFLpbCc9yCzeTuWJg4qWnTs9BaLr5CDYcnJ5UnGmgLo8JBgk", coin:.bitcoin)print(privateKey.publicKey.address)
//128BCBZndgrPXzEgF4QbVR3jnQGwzRtEz5WalletKit is released under the MIT License.






