Skip to content

Send ETH to contract address. #259

@rachkumar

Description

@rachkumar

Hi,

I need to send ETH to contract address..But am getting issue as failed to fetch gas estimate.

My code:

    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)
    }
 
    Please help to sort this issue....

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions