@@ -53,7 +53,7 @@ class ViewController: UIViewController {
53
53
let constractAddress = EthereumAddress ( " 0x45245bc59219eeaaf6cd3f382e078a461ff9de7b " )
54
54
let gasPriceResult = web3Main. eth. getGasPrice ( )
55
55
guard case . success( let gasPrice) = gasPriceResult else { return }
56
- var options = Web3Options ( )
56
+ var options = Web3Options . defaultOptions ( )
57
57
options. gasPrice = gasPrice
58
58
options. from = EthereumAddress ( " 0xE6877A4d8806e9A9F12eB2e8561EA6c1db19978d " )
59
59
let parameters = [ ] as [ AnyObject ]
@@ -69,6 +69,9 @@ class ViewController: UIViewController {
69
69
guard case . success( let bkxBalance) = bkxBalanceResult, let bal = bkxBalance [ " 0 " ] as? BigUInt else { return }
70
70
print ( " BKX token balance = " + String( bal) )
71
71
72
+ // Test token transfer on Rinkeby
73
+
74
+
72
75
var eip67Data = Web3 . EIP67Code. init ( address: EthereumAddress ( " 0x6394b37Cf80A7358b38068f0CA4760ad49983a1B " ) )
73
76
eip67Data. gasLimit = BigUInt ( 21000 )
74
77
eip67Data. amount = BigUInt ( " 1000000000000000000 " )
@@ -99,7 +102,7 @@ class ViewController: UIViewController {
99
102
print ( " Address mismatch " )
100
103
}
101
104
guard case . success( let sendingResult) = sendResult else { return }
102
- let txid = sendingResult [ " txhash " ] as? String
105
+ let txid = sendingResult [ " txhash " ]
103
106
print ( " On Rinkeby TXid = " + txid!)
104
107
105
108
//Send ETH on Rinkeby using BIP32 keystore. Should fail due to insufficient balance
@@ -114,6 +117,23 @@ class ViewController: UIViewController {
114
117
print ( err)
115
118
}
116
119
120
+
121
+ guard case . success( let gasPriceRinkeby) = web3Rinkeby. eth. getGasPrice ( ) else { return }
122
+ web3Rinkeby. addKeystoreManager ( keystoreManager)
123
+ var tokenTransferOptions = Web3Options . defaultOptions ( )
124
+ tokenTransferOptions. gasPrice = gasPriceRinkeby
125
+ tokenTransferOptions. from = ks? . addresses? . first!
126
+ let testToken = web3Rinkeby. contract ( Web3 . Utils. erc20ABI, at: EthereumAddress ( " 0xa407dd0cbc9f9d20cdbd557686625e586c85b20a " ) , abiVersion: 2 ) !
127
+ let intermediateForTokenTransfer = testToken. method ( " transfer " , parameters: [ EthereumAddress ( " 0x6394b37Cf80A7358b38068f0CA4760ad49983a1B " ) , BigUInt ( 1 ) ] as [ AnyObject ] , options: tokenTransferOptions) !
128
+ let tokenTransferResult = intermediateForTokenTransfer. send ( password: " BANKEXFOUNDATION " )
129
+ switch tokenTransferResult {
130
+ case . success( let res) :
131
+ print ( " Token transfer successful " )
132
+ print ( res)
133
+ case . failure( let error) :
134
+ print ( error)
135
+ }
136
+
117
137
//Balance on Rinkeby
118
138
let balanceResult = web3Rinkeby. eth. getBalance ( address: coldWalletAddress)
119
139
guard case . success( let balance) = balanceResult else { return }
0 commit comments