Отправьте ETH на адрес контракта, используя web3 в swift - PullRequest
0 голосов
/ 13 апреля 2020

Я использую web3 в моем приложении по ссылке: https://github.com/matter-labs/web3swift.

Мне нужно отправить ETH на адрес контракта.

Что я пробовал:

let walletAddress = keystoreManager.addresses! [0]

let contractABI = Web3Utils.erc20ABI // Contract ABI
let contractAddressVal = EthereumAddress(contractAddress)!
let abiVersion = 2 // Contract ABI version
let contract = web3Main.contract(contractABI, at: contractAddressVal, abiVersion: abiVersion)!
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
var options = TransactionOptions.defaultOptions
options.value = amount
options.from = walletAddress
options.gasPrice = .manual(BigUInt("10000000000"))
options.gasLimit = .manual(BigUInt("70000"))

let tx = contract.write()!

do {
    let transaction = try tx.send(password: "", transactionOptions: options)
    print("output", transaction)
} catch(let err) {
  print("err", err)
}

Am getting the issue as failed to fetch gas estimate.

Please help to sort out this issue....
...