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

Web3swift.Web3Error.processingError(desc: "Failed to fetch nonce"). #285

Closed
ayjayem opened this issue Oct 19, 2020 · 5 comments
Closed

Web3swift.Web3Error.processingError(desc: "Failed to fetch nonce"). #285

ayjayem opened this issue Oct 19, 2020 · 5 comments
Labels
wontfix This will not be worked on

Comments

@ayjayem
Copy link

ayjayem commented Oct 19, 2020

Hi there,

This seems like a great library - thanks so much for providing!

I am facing a stubborn issue: Fatal error: 'try!' expression unexpectedly raised an error: Web3swift.Web3Error.processingError(desc: "Failed to fetch nonce").

I am importing one of my own addresses, and then trying to send a transaction using the snippet below. I'm sure I'm just doing something silly - any assistance would be very much appreciated:

let web3 = Web3.InfuraMainnetWeb3()
let walletAddress = EthereumAddress(wallet!.address!)!

let contractMethod = "approve"
let DAIcontractAddress = EthereumAddress(daiAddressString)!
let abiVersion = 2

let approvalUnits = "1000"
let approveAmount = Web3.Utils.parseToBigUInt(approvalUnits, units: .wei)!

let approveAddress = EthereumAddress(erc20AddressString)!

let parameters: [AnyObject] = [approveAddress as AnyObject, approveAmount as AnyObject] as [AnyObject]
let extraData: Data = Data()
let contract = web3.contract(Web3.Utils.erc20ABI, at: DAIcontractAddress, abiVersion: abiVersion)!
var options = TransactionOptions.defaultOptions
options.from = walletAddress
options.gasPrice = .automatic
options.gasLimit = .automatic
let tx = contract.write(
    contractMethod,
    parameters: parameters,
    extraData: extraData,
    transactionOptions: options)!

_ = try! tx.send(password: password)
@ayjayem
Copy link
Author

ayjayem commented Oct 19, 2020

Using my own Infura endpoint resolved this particular error.

Now instead I'm getting the following error: typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array but found a dictionary instead.", underlyingError: nil))

Again, I'm sure I'm just doing something silly. Leaving this here in case anyone else encounters something similar.

@ayjayem
Copy link
Author

ayjayem commented Oct 19, 2020

I did do something silly: needed to attach the keystore manager to my web3 instance...

web3.addKeystoreManager( KeystoreManager( [keystore] ) )

Thanks again for the library!

@ayjayem ayjayem closed this as completed Oct 19, 2020
@skywinder
Copy link
Collaborator

skywinder commented Oct 20, 2020

@alexandermucalov, you are always welcome. Glad that you found it useful. 👍

Here are some followup comments regarding this:

Keep in mind that enchantments & pull requests to this repo are eligible for the GitCoin grant program we received.
So if you are willing to contribute - don't hesitate to do this. I will make a bounty (by ETH or Dai) to reward your contribution!

so let me know if you can

  1. improve the documentation and codebase:
  • add convenience methods to this library (if you can know how to improve the developer experience with web3swift and keystore management as an example)
  • describe how to set up or how setup your Infura endpoint - it would be super helpful for others. sure because many issues happened because of public Infura node, as it described in this issue: Return nil on tx.call() (was not there few days ago)  #239

ps.
I would like to know on which project are you working on. Feel free to add your Dapp to the section: https://github.com/matter-labs/web3swift#projects-that-are-using-web3swift

@skywinder skywinder added the wontfix This will not be worked on label Oct 20, 2020
@skywinder
Copy link
Collaborator

@alexandermucalov since you are active user, would you like to help with this for the bounty?

@skywinder skywinder reopened this Oct 20, 2020
@skywinder skywinder removed the wontfix This will not be worked on label Oct 20, 2020
@skywinder
Copy link
Collaborator

@AnnaYatsun1 please kindly check this issue and how web3.addKeystoreManager( KeystoreManager( [keystore] ) ) works with latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants