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,050 points
61 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
• 27,620 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,050 points
28 views
0 votes
1 answer
0 votes
1 answer

How to create a cryptocurrency based reward system using Ethereum?

I doubt that you'd need a decentralized ...READ MORE

answered May 30, 2018 in Blockchain by Shashank
• 10,330 points
74 views
0 votes
1 answer
0 votes
1 answer
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
• 27,620 points
55 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
• 27,620 points
29 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
• 27,620 points
123 views