此仓库是 Loois团队 提供的方便开发者接入钱包的SDK.
Loois iOS SDK提供了常规的以太坊钱包功能和基于路印协议Relay的交易等功能及便捷API.
- 生成钱包
- 导出钱包(#导出钱包)
- 修改Keystore密码
- 删除钱包
- 交易签名
- getTransactionCount
- sendRawTransaction
- call
- getPrice
- estimateGas
- getTransactionByHash
- getBalance
- getPriceQuote
- getMarkets
- getSupportedTokens
- getTransactions
- getExchangetMarket
- notifyTransactionSubmitted
- searchLocalTokens
- registerToken
- unlockWallet
- getNonce
- getBalance
- getPriceQuote
- loopringTickers
- portfolio
- tickers
- marketcap
- depth
- trends
- pendingTx
pod 'LooisKit' ~> '0.0.5'
let keystore = EtherKeystore(keysSubfolder: "/keystore")
let buildType: BuildType = .create(newPassword: [YOUR PASSWORD])
keystore.buildWallet(type: buildType, completion: { (result) in
print("wallet address: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
let buildType: BuildType = .mnemonic(words: [YOUR MNEMONICS WORDS ARRAY], newPassword: [YOUR PASSWORD])
keystore.buildWallet(type: buildType, completion: { (result) in
print("wallet address: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
let buildType: BuildType = .privateKey(privateKey: [YOUR PRIVATE KEY STRING], newPassword: [YOUR PASSWORD])
keystore.buildWallet(type: buildType, completion: { (result) in
print("wallet address: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
let buildType: BuildType = .keystore(string: [YOUR KEYSTORE STRING], password: [YOUR PASSWORD], newPassword: [YOUR PASSWORD])
keystore.buildWallet(type: buildType, completion: { (result) in
print("wallet address: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
guard let wallet = keystore.wallet(for: [THE WALLET ADDRESS STRING]) else { return }
let exportType: ExportType = .privateKey(wallet: wallet, password: [YOUR PASSWORD])
keystore.exportWallet(type: exportType, completion: { (result) in
print("exported keystore string: ", result.value, "or error: ", result.error)
}
注:Loois SDK 不以任何方式存储用户的助记符
let keystore = EtherKeystore(keysSubfolder: "/keystore")
guard let wallet = keystore.wallet(for: [THE WALLET ADDRESS STRING]) else { return }
let exportType: ExportType = .keystore(wallet: wallet, password: [YOUR PASSWORD], newPassword: [YOUR PASSWORD])
keystore.exportWallet(type: exportType, completion: { (result) in
print("exported keystore string: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
guard let wallet = keystore.wallet(for: [THE WALLET ADDRESS STRING]) else { return }
keystore.update(wallet: wallet, password: [YOUR PASSWORD], newPassword: [YOUR PASSWORD], completion: { (result) in
print("update result is: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
guard let wallet = keystore.wallet(for: [THE WALLET ADDRESS STRING]) else { return }
keystore.delete(wallet: wallet, password: "12345678", completion: { (result) in
print("delete result is: ", result.value, "or error: ", result.error)
}
let keystore = EtherKeystore(keysSubfolder: "/keystore")
guard let wallet = keystore.wallet(for: [THE WALLET ADDRESS STRING]) else { return }
let contractAddress = EthereumAddress(string: [ADDRESS]) // WETH
let encoder = FunctionRawEncoder.transfer(to: EthereumAddress(string: [ADDRESS])!,
amount: 1_000_000_000_000_000)
let st = RawTransaction(nonce: 539,
gasPrice: 5140490000,
gasLimit: 60000,
value: 0,
to: contractAddress,
data: encoder.encodedData,
functionRaw: encoder.function.signature)
let signed = HomesteadSigner().sign(transaction: st, wallet: wallet, password: [YOUR PASSWORD])
print("signed string: ", signed.value?.hexString, "or error: ", signed.error)