Boilertalk / Web3.swift

A pure swift Ethereum Web3 library
MIT License
639 stars 188 forks source link

How to write Contract ABI functions swift ios #111

Open text4lilac opened 2 years ago

text4lilac commented 2 years ago

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