Skip to content
Petr Korolev edited this page Oct 25, 2018 · 44 revisions

How to create raw transaction using web3swift?

    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)

     }     

[TODO - Answer @anton]

source: https://stackoverflow.com/questions/48877073/how-to-create-raw-transaction-using-web3swift


Clone this wiki locally