-
Notifications
You must be signed in to change notification settings - Fork 483
Closed
Description
I get this message Failed to fetch gas estimate
for try tx.send(password: password)
public func sendTokenSync(to toAddress: String, contractAddress: String, amount: String, password: String, gasPrice:
String?) throws -> String {
if access == .viewOnly { throw WalletError.notAllowedAccess }
guard let myAddress = address,
let myEthereumAddress = EthereumAddress(myAddress),
let toEthereumAddress = EthereumAddress(toAddress),
let erc20ContractAddress = EthereumAddress(contractAddress),
let contract = web3Instance.contract(Web3.Utils.erc20ABI, at: erc20ContractAddress, abiVersion: 2) else {
throw WalletError.invalidAddress
}
guard let decimals = try? decimalsForToken(contractAddress: contractAddress) else {
throw WalletError.unexpectedResult
}
var options = TransactionOptions.defaultOptions
options.value = Web3.Utils.parseToBigUInt(amount, decimals: decimals)
options.from = myEthereumAddress
if let gasPrice = gasPrice,
let wei = Web3.Utils.parseToBigUInt(gasPrice, units: .eth) {
options.gasLimit = .manual(defaultGasLimitForTokenTransfer)
options.gasPrice = .manual(wei)
}
guard let tx = contract.write("transfer", parameters: [toEthereumAddress, options.value] as [AnyObject], extraData: Data(), transactionOptions: options) else {
throw WalletError.unexpectedResult
}
let txResult = try tx.send(password: password)
return txResult.hash
}
same for automatic gasLimit and gasPrice
Metadata
Metadata
Assignees
Labels
No labels