@@ -230,36 +230,26 @@ transactionOptions: options)!
230
230
self.receiverAddressString = self.walletAddressTF.text //get receiver address string
231
231
print("Receiver address is : ", self.receiverAddressString ?? " ")
232
232
self.etheriumAccountAddress = self.wethioKeystoreManager?.addresses.first?.address //get sender address in string
233
-
234
-
235
- //convert address string into etherium addresss
233
+ /*
234
+ convert address string into etherium addresss
235
+ */
236
236
let senderEthAddress = EthereumAddress(self.etheriumAccountAddress ?? "")
237
+ //Run on backgrounnd tread
237
238
DispatchQueue.global(qos: .background).async {
238
239
do {
239
240
//Convert receiver address in to etherium address
240
241
let toaddress = EthereumAddress(self.receiverAddressString ?? "")
241
-
242
- //Create web3 options
243
- var options = Web3Options.defaultOptions()
244
-
245
- //Convert amount into BIGINT
246
- let amountDouble = BigInt((Double(yourCoin) ?? 0.1)*pow(10, 18))
247
-
248
- //Here i am using 0.1 as an default value please use validation for amount (coin or token)
242
+ var options = Web3Options.defaultOptions() //Create web3 options
243
+ let amountDouble = BigInt((Double(yourCoin) ?? 0.1)*pow(10, 18)) //Convert amount into BIGINT
249
244
print("Total amount in double value : ", amountDouble)
245
+ var amount = BigUInt.init(amountDouble) //Convert amount in BIG UI Int
246
+ let estimateGasPrice = try wInstance.eth.getGasPrice() //estimate gas price
250
247
251
- //Convert amount in BIG UI iNt
252
- var amount = BigUInt.init(amountDouble)
253
-
254
- //get gas price
255
- let estimateGasPrice = try wInstance.eth.getGasPrice()
256
248
guard let eGasReult = self.estimatedGasResult else {
257
249
print("Unable to find gas price")
258
250
return
259
251
}
260
-
261
- //Get nonce
262
- let nonce = try wInstance.eth.getTransactionCount(address: senderEthAddress)
252
+ let nonce = try wInstance.eth.getTransactionCount(address: senderEthAddress) //Get nonce or transaction count
263
253
print("Is the Transaction count", nonce)
264
254
let fee = estimateGasPrice * eGasReult
265
255
/*
@@ -273,24 +263,17 @@ transactionOptions: options)!
273
263
sendTransactionIntermediateOptions.from = senderEthAddress
274
264
sendTransactionIntermediateOptions.gasLimit = eGasReult
275
265
sendTransactionIntermediateOptions.gasPrice = estimateGasPrice
276
-
277
- var tokenTransactionIntermediate: TransactionIntermediate!
266
+ var tokenTransactionIntermediate: TransactionIntermediate! //Create transaction intermediate
278
267
tokenTransactionIntermediate = try wInstance.contract("Your custom contract ABI string", at: contractAddress).method("transfer", args: toaddress, amount, options: sendTransactionIntermediateOptions)
279
-
280
268
let mainTransaction = try tokenTransactionIntermediate.send(options: sendTransactionIntermediateOptions, onBlock: "latest")
281
-
282
- print(mainTransaction.hash, "is the hash")
269
+ print(mainTransaction.hash, "is the hash of your transaction")
283
270
}
284
271
}
285
272
}
286
273
}
287
274
288
275
```
289
276
290
-
291
-
292
-
293
-
294
277
### Web3View example
295
278
296
279
You can see how to our demo project: ** WKWebView with injected "web3" provider** :
0 commit comments