Skip to content

Commit 26e42bd

Browse files
Update README.md
Updated doc for Contract Transaction
1 parent 1358e41 commit 26e42bd

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

README.md

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -230,36 +230,26 @@ transactionOptions: options)!
230230
self.receiverAddressString = self.walletAddressTF.text //get receiver address string
231231
print("Receiver address is : ", self.receiverAddressString ?? " ")
232232
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+
*/
236236
let senderEthAddress = EthereumAddress(self.etheriumAccountAddress ?? "")
237+
//Run on backgrounnd tread
237238
DispatchQueue.global(qos: .background).async {
238239
do {
239240
//Convert receiver address in to etherium address
240241
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
249244
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
250247
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()
256248
guard let eGasReult = self.estimatedGasResult else {
257249
print("Unable to find gas price")
258250
return
259251
}
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
263253
print("Is the Transaction count", nonce)
264254
let fee = estimateGasPrice * eGasReult
265255
/*
@@ -273,24 +263,17 @@ transactionOptions: options)!
273263
sendTransactionIntermediateOptions.from = senderEthAddress
274264
sendTransactionIntermediateOptions.gasLimit = eGasReult
275265
sendTransactionIntermediateOptions.gasPrice = estimateGasPrice
276-
277-
var tokenTransactionIntermediate: TransactionIntermediate!
266+
var tokenTransactionIntermediate: TransactionIntermediate! //Create transaction intermediate
278267
tokenTransactionIntermediate = try wInstance.contract("Your custom contract ABI string", at: contractAddress).method("transfer", args: toaddress, amount, options: sendTransactionIntermediateOptions)
279-
280268
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")
283270
}
284271
}
285272
}
286273
}
287274
288275
```
289276

290-
291-
292-
293-
294277
### Web3View example
295278

296279
You can see how to our demo project: **WKWebView with injected "web3" provider**:

0 commit comments

Comments
 (0)