Web3.swift icon indicating copy to clipboard operation
Web3.swift copied to clipboard

How to write Contract ABI functions swift ios

Open text4lilac opened this issue 3 years ago • 0 comments

i have made an demo app using walletconnectswift library for connecting to rainbow wallet and i want to write contract functions given in this link below: https://ropsten.etherscan.io/address/0x1c5509db908b34d81566f48780caa22e918c228a#writeContract

i have tried but not working. can i get an example of how it works. can i get example of approve function

the code i have tried is below:

let web3 = Web3(rpcURL: "https://ropsten.infura.io/v3/4cca371cb77c4935bdb1a1381b2ffbe2") guard let contractAddress = getAddress(hex: "0x1C5509DB908b34D81566f48780Caa22E918C228a") else { return }

    guard let spenderAddress = getAddress(hex: Constants.spenderAddress) else { return }
    
    contract = web3.eth.Contract(type: GenericERC20Contract.self, address: contractAddress)
    
    contract.approve(spender: spenderAddress, value: 10000).call { result, error in
        
    }

but it gives me error that operation cannot be completed

text4lilac avatar Dec 25 '21 09:12 text4lilac