Using web3swift to create raw transaction

0 votes
I want to use web3swift to create a raw transaction but not getting how to. Can someone provide the code for this?
Jul 31, 2018 in Blockchain by slayer
• 29,350 points
801 views

1 answer to this question.

0 votes

Here you go:

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)

 }     

Source: https://medium.com/coinmonks/getting-started-with-web3swift-1a2454481f70

answered Jul 31, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

How to create raw transaction using web3swift?

var options = Web3Options.defaultOptions() options.gasLimit = BigUInt(21000) options.from = ...READ MORE

answered Sep 17, 2018 in Blockchain by slayer
• 29,350 points
677 views
0 votes
1 answer
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,670 points
650 views
0 votes
3 answers
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,234 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
726 views
+1 vote
1 answer
0 votes
1 answer

How to transact custom token instead of ethers using JSON rpc?

First create your custom token. Then develop ...READ MORE

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

How to create a Genesis Block in a Private Network?

{     "nonce": "0x0000000000000042",     "difficulty": "0x000000100",     "alloc": {     },     "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",     "coinbase": "0x0000000000000000000000000000000000000000",     "timestamp": "0x00",     "parentHash": ...READ MORE

answered Jul 12, 2018 in Blockchain by digger
• 26,740 points
1,806 views
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