Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance member 'contract' cannot be used on type 'web3'; did you mean to use a value of this type instead? #352

Closed
Najim-hub opened this issue Aug 4, 2021 · 5 comments

Comments

@Najim-hub
Copy link

Najim-hub commented Aug 4, 2021

This line of code causes error's when I try to test the send ether method

Line: let contract = web3.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!

This is a swift code:

` let value: String = "1.0" // In Ether
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let toAddress = EthereumAddress(toAddressString)!
let contract = web3.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!

    let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
    var options = TransactionOptions.defaultOptions
    options.value = amount
    options.from = walletAddress
    options.gasPrice = .automatic
    options.gasLimit = .automatic
    let tx = contract.write(
    "fallback",
    parameters: [AnyObject](),
    extraData: Data(),
    transactionOptions: options)!`
@Najim-hub
Copy link
Author

Can someone like help me please

@RaviRanjan-11
Copy link
Contributor

Hi Please share screen shot of your error

@Najim-hub
Copy link
Author

@veerchauhan here's the screenshot, thank you for the response, what I'm trying to do is create a method to send etheruem
Screen Shot 2021-08-04 at 6 26 11 PM

in addition I'm having an error with the check Balance method, it says I've reached the maximum amount of times for a request
Screen Shot 2021-08-04 at 6 28 43 PM

again thank you

@RaviRanjan-11
Copy link
Contributor

RaviRanjan-11 commented Aug 10, 2021

Please find the below code

`

  func send() {
    var web3Instance: web3?
    guard let wInstance = web3Instance else {return}
    var sendTransactionIntermediateOptions = TransactionOptions.defaultOptions
    let contractAddress = EthereumAddress("YourcontractString")
    print(contractAddress?.address)
    let amount = "0.03"
    let walletAddress = EthereumAddress("yourAddress")
    let receiverWalletAddress = EthereumAddress("ReciverAddress")

    let contract = wInstance.contract(Web3.Utils.coldWalletABI, at: contractAddress)
    
}

`

You can always follow the documentation
#closed

@Iysbaera
Copy link
Collaborator

Iysbaera commented Nov 5, 2021

Authour of this issue haven't replied, so I suppose it was resolved and thus closing this issue.

To anyone still experiencing similar problems, feel free to reopen it.

@Iysbaera Iysbaera closed this as completed Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Iysbaera @RaviRanjan-11 @Najim-hub and others