Rockside Wallet Sdk IOS
Installation
CocoaPods
Add WalletSdk to your Podfile:
pod 'RocksideWalletSdk', '~> 0.2'Then run the following command:
$ pod installSetup
import RocksideWalletSdk
let rockside = Rockside(token: "YOUR_TOKEN", chain:.ropsten)
Use your API KEY to create your mobile app token. You have to use your app bundle identitifer as domain. See our Rockside Token Documentation.
Identity SmartWallet
Create APP's identity SmartWallet
rockside.createIdentity() { (result) in
switch result {
case .success(let txhash):
// Here is the hash of the tx deploying the smartwallet
// To know when the TX is mined use : rockside.rpc.waitTxToBeMined(txHash: txHash)
print(txhash)
//created identity is available as rockside.identity
print(rockside.identity?.eoa.ethereumAddress)
print(rockside.identity?.ethereumAddress)
break
case .failure(let error):
print(error)
break
}
}Restore Identity Smartwallet
rockside.restoreIdentity(mnemonic: MNEMPONIC, address: IDENTITY_SMART_CONTRACT_ADDRESS)
//restored identity is available as rockside.identity
print(rockside.identity?.eoa.ethereumAddress)Relay transaction
identity.relayTransaction(to: "0x2c68bfBc6F2274E7011Cd4AB8D5c0e69B2341309",
value: 0,
data: "0x") { (result) in
switch result {
case .success(let txhash):
print(txhash)
break
case .failure(let error):
print(error)
break
}
}ETH Balance
identity.getBalance() { (result) in
switch result {
case .success(let balance):
print(balance)
break
case .failure(let error):
print(error)
break
}
}ERC20: Balance
identity.getErc20Balance(ercAddress: ERC20_ADDRESS) { (result) in
switch result {
case .success(let balance):
print(balance)
break
case .failure(let error):
print(error)
break
}
}ERC20: Approve
identity.erc20Approve(ercAddress: ERC20_ADDRESS, spender: ADDRESS_TO_APPROVE, value: APPROVED_AMOUNT) { (result) in
switch result {
case .success(let txhash):
print(txhash)
break
case .failure(let error):
print(error)
break
}
}ERC20: Transfer
identity.erc20Transfer(ercAddress: ERC20_ADDRESS, to: DEST_ADDRESS, value: AMOUNT_TO_SEND) { (result) in
switch result {
case .success(let txhash):
print(txhash)
break
case .failure(let error):
print(error)
break
}
}Whitelist: Updade
identity.updateWhiteList(eoa: EOA_TO_UPDATE, value:true) { (result) in
switch result {
case .success(let txhash):
print(txhash)
break
case .failure(let error):
print(error)
break
}
}Whitelist: Is EOA whitelisted
identity.isEOAWhiteListed(eoa: EOA_TO_UPDATE) { (result) in
switch result {
case .success(let result):
print(result) // true or false
break
case .failure(let error):
print(error)
break
}
}RPC
Transaction Receipt
rockside.rpc.transactionReceipt(txHash: TX_HASH) { (result) in
switch result {
case .success(let receipt): //TransactionReceipt type
print(receipt.status)
break
case .failure(let error):
print(error)
break
}
}Wait tx to be mined
rockside.rpc.waitTxToBeMined(txHash: TX_HASH) { (result) in
switch result {
case .success(let receipt): //TransactionReceipt type
print(receipt.status)
break
case .failure(let error):
print(error)
break
}
}Storage
Store your identity using Keychain.
Store
try? rockside.storeIdentity()Retrieve
try? rockside.retrieveIdentity()
//retrieved identity is available as rockside.identity
print(rockside.identity?.eoa.ethereumAddress)
print(rockside.identity?.ethereumAddress)Clear
try? rockside.clearIdentity()Integration Tests
To run integration tests, add the following environment variables in test scheme:
INTEGRATION_TEST=true
ROCKSIDE_TOKEN=A_TOKEN_CREATED_WITH_YOUR_APIKEY // domain must be com.apple.dt.xctest.tool
License
Released under the MIT license.