-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Uncaught (in promise) TypeError: Cannot read property 'indexOf' of undefined #292
Comments
My guess is that Try: let provider = new ethers.providers.Web3Provider(this.state.web3);
// Change this to the provider
let contract = new ethers.Contract(process.env.CONTRACT_ADDRESS, process.env.CONTRACT_ABI, provider);
let privateKey = process.env.PRIVATE_KEY;
// Change this to the provider
let wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
let contractWithSigner = contract.connect(wallet);
let tx = contractWithSigner.addUpdatedFishData(this.state.tagid, this.state.newTagId, this.state.processType).then((result) => {
console.log(result);
}); If let provider = new ethers.providers.Web3Provider(this.state.web3.currentProvider); Let me know if that helps. :) |
Thanks for the response :). Actually, the provider is ether.js provider. Since the code below was in a helper file, I forgot to mention it in the question.
So this.state.web3 is web3Provider. Since web3 name was already used, I did not change it but rather changed its contents. The same code works when calling other functions. Also there was another function for which if the tag id was around the value 1000, it worked but with higher values e.g 8000, I got the same error. I hope my question is clear :) |
Hmmm... I think I need more context then. :s Can you include the ABI signature for that call? And can you maybe try running a bunch of values against the tag to see if there is a pattern to which ones work and which do not? |
This is the ABI for that function.
Currently this one doesn't work for any values. I tried. The error is mapped to this place in the ethers.js file (The first if)
|
I see, I see. So there was an error getting a response, but for some reason responseText wasn't populated in the error. I should certainly add a check in that block. I will add that tomorrow. In the mean time, to help you debug, you should be able to just comment out all those And I'll update this ticket once the new code is live. |
Ok nice. Thanks for the help :) |
In my case, the actual error was this:
How can I set gas limit while calling the contract function to ensure gas doesn't run out while the function is being executed? |
You can pass in 1 additional parameter, which is a dictionary of overrides, so if foo takes in 2 parameters: But if you are getting that error, it probably means tour contract is throwing an error, which has the same effect as basically requiring more gas than is allowed. |
Ok.. Thanks again. Will check the contract :) |
Also, if you are using truffle, try blowing away the build. Sometimes it updates the ABI but not the bytecode or address, so it lets you call functions that don’t actually exist. :) |
Yeah I am using truffle. Ok will try that :) |
This should be fixed now, at least as far as nested internal errors shadowing the actual errors. :) Let me know if you still have problems, or feel free to open another issue to track other problems. Thanks! :) |
Thanks :) |
Merge commit '3736a1571480a0f69d632d6fc3bde549cbe46162' into fix/tslib * commit '3736a1571480a0f69d632d6fc3bde549cbe46162': (41 commits) Updated dist files. Added automatic event parsing for contract transaction receipts from tx.wait. Added ability to wait for a specific number of confirmations (ethers-io#229). Fix for geth-etc (official geth is fine), which returns Receipts before the blockHash is synced to the database. Fixed confirmations tests and bootstrap fast blockNumber. Added confirmations to TransactionResponse (ethers-io#156, ethers-io#238). Fixed nested errors for providers that were masking true error (ethers-io#292). Updated dist files. Added version to errors. Fixed French and Spanish for browsers without Uint8Array.forEach. Added French and Spanish includes to phantomjs test page. Increased timeout for querying npm registry. Updated dist files. Added French and Spanish wordlist dist files. Added French and Spanish BIP-39 wordlists (ethers-io#191). Added support for JSON serialized BigNumbers in the constructor (ethers-io#288). Fixed scrypt for long passwords (ethers-io#223). Updated dist files. Added chainId as supported override for contract transactions. Fixed wildcard events and made nested events more robust (ethers-io#289). ... Conflicts: dist/ethers.min.js dist/ethers.min.js.map package-lock.json
I get this error when trying to write data. This error only occurs with some function calls.
Error :
Uncaught (in promise) TypeError: Cannot read property 'indexOf' of undefined
Sample Code of where error is encountered:
Is it something to deal with tagid as it is my index in solidity mapping?
The text was updated successfully, but these errors were encountered: