Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Can not send transaction with value to contract !! #297

Open
quocnhan opened this issue May 22, 2019 · 1 comment
Open

Can not send transaction with value to contract !! #297

quocnhan opened this issue May 22, 2019 · 1 comment

Comments

@quocnhan
Copy link

depositAward is a function in my contract, it doen't need arguments and it is payable so when i try to interact with my contract in iOS, it have an error that is Failed to fetch gas estimate, but it ok in web3.js . So can anyone help me ?

Here is my code :

...
web3.keystoreManager = bip32keystoreManager
            do {
                let challengeAddress = Address(address) // this is my contract address
                var options = Web3Options.default
                options.value = BigUInt(1000000000000000) // this is value i want to send to contract
                let gasPrice = try web3.eth.getGasPrice()
                options.gasPrice = gasPrice
                options.from = bip32keystoreManager.addresses[0] // this function for geting my current account
                options.to = challengeAddress // i want to send tx to my contract
                let contract = try web3.contract(Web3.Utils.customABI, at: challengeAddress) 
                let transactionIntermediate = try contract.method("depositAward", options: options)
                let transaction = try transactionIntermediate.send(password: Constant.password, options: options, onBlock: "latest")
                let txid = transaction.hash
                print(transaction)
                resultHandler(.success(txid))
            } catch {
                Logger.error(message: error)
                resultHandler(.failure(error))
            }
@skywinder
Copy link
Contributor

We moved our development to the new repo
➡️https://github.com/matterinc/web3swift ⬅️
Feel free continue discussion in the new repository. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants