如何使用web3swift创建原始事务?

时间:2018-02-20 02:40:57

标签: ios swift blockchain ethereum web3swift

我正在开发一个与区块链相关的项目,需要弄清楚原始交易是如何实现的。到目前为止,我没有参考。

我尝试了matterinc/web3swift但无法得到确切的内容。

1 个答案:

答案 0 :(得分:0)

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)

 }     

请参阅此博客,在此博客中,我有一个帐户,并在以太网和ERC20代币中创建交易。

https://medium.com/@shivangpandey195/getting-started-with-web3swift-1a2454481f70