How to create raw transaction using web3swift

0 votes
I need to create a raw transaction using web3swift for my project. I dont know how to do that. Can someone tell me how to do it?
Sep 17, 2018 in Blockchain by digger
• 26,740 points
908 views

1 answer to this question.

0 votes
var options = Web3Options.defaultOptions()

options.gasLimit = BigUInt(21000)

options.from = self.bip32keystore?.addresses?.first!

let amountDouble = Int((Double(amount) ?? 0.0)*pow(10, 18))

let am = BigUInt.init(amountDouble)

options.value = am

let estimatedGasResult =   self.web3Rinkeby?.contract(Web3.Utils.coldWalletABI, at: toaddress)!.method(options: options)!.estimateGas(options: nil)

guard case .success(let estimatedGas)? = estimatedGasResult else {return}

options.gasLimit = estimatedGas

var intermediateSend = self.web3Rinkeby?.contract(Web3.Utils.coldWalletABI, at: toaddress, abiVersion: 2)!.method(options: options)!

intermediateSend = self.web3Rinkeby?.contract(Web3.Utils.coldWalletABI, at: toaddress, abiVersion: 2)!.method(options: options)!

let sendResult = intermediateSend?.send(password: pass)

switch sendResult {

    case .success(let r)?:

    print("Sucess",r)

  case .failure(let err)?:

  print("Eroor",err)

 case .none:

 print("sendResultBip32",sendResult)

 }     
answered Sep 17, 2018 by slayer
• 29,370 points

Related Questions In Blockchain

0 votes
1 answer

Using web3swift to create raw transaction.

Here you go: var options = Web3Options.defaultOptions() options.gasLimit = ...READ MORE

answered Jul 31, 2018 in Blockchain by digger
• 26,740 points
1,005 views
0 votes
1 answer

How to set fee in raw bitcoin transaction using btcutil

To answer your question, the settxfee is ...READ MORE

answered Mar 24, 2022 in Blockchain by Rahul
• 9,680 points
926 views
0 votes
3 answers
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,740 points
1,004 views
+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP