-
Notifications
You must be signed in to change notification settings - Fork 552
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) ReferenceError: Web3 is not defined #11
Comments
I confirm, I got same error. I tried many things but same result... Help please ? thanks |
install web3 (npm install web3) and add
above
inside the index.html This is necessary since metamask stopped injecting web3 I'll make a pr after verifying this works :) |
…is not defined This issue is due to the fact that metamask no longer injects web3 by default package.json - added web3 dependency src/index.html - added web3 dependency
okay took me a while but it seems to be necessary now to set the address which is used to send the transaction. please keep in mind, I'm doing this tutorial to learn as well :) so my solution probably isn't perfect. I will add a pr and improve if necessary. |
Hello jdohm, It's working with version 0.20.6 and adding src in html ;) thanks Why we use the last version web3, we got this error ? |
Because it contains braking changes (see Semantic Versioning). In this case, some functions called from truffle-contracts and in the tutorial code changed. To use the newest web3 library you have to also update the tutorial code and the used truffle version. See how to use newer versions in a newer tutorial: github dbank YouTube dbank tutorial |
I believe this should be |
This worked for me. |
I think this should be a separate issue. This issue occurs when invoking the functions in the contract. It has nothing to do with Web3 not available. Anyway, the solution you specified here works i.e. a |
I was able to get it working by |
Yes I have already placed in package json. Running the command outputs the web3 presence: [email protected] /Users/utkarshbisht/block8/eth-todo |
@ashubisht as stated above please install version 0.20.6 instead of 1.xx.xx |
This really helped. Thanks @jdohm 👍 |
My guess would be that in the past metamask not only injected web3 but also set the default account. But I toke a quick look at the metamask code and couldn't find such a thing so I'm not sure. |
Ok, @jdohm.I'm pretty new to this, so I'm also learning all these new concepts and workflows. Thanks for sharing your views. |
I copied the changes you commited on your fork, @jdohm, and that fixed the issue for me. Thank you. |
Thanks @jdohm for your fixes. I came up with the same solutions after debugging for a couple hours. Should have have just read this issue!! There is still an issue if you change your metamask address between page refreshes. I worked around it by adding |
If you want to make a PR feel free to include my work ( |
Hello, This works for "Uncaught (in promise) error: invalid address" also. Dankeee @jdohm :D |
Confirming that it works when adding this script after running "npm install [email protected]". |
Can confirm the web3.eth.defaultAccount = web3.eth.accounts[0] solution works for getting rid of the invalid address error. Now having an issue making the added tasks actually show up but I don't think it's related to this...yet. Dev error: I didn't redeploy the smart contract which is why the txn were counted in Ganache but literally not showing up on the page. I didn't see the checkbox for the Dapp University task but didn't put it together. |
I was having the same issue, I did this command => npm install [email protected] |
check if you use web3.js or web3.min.js |
Confirm by installing this dependency:-
Make sure the order for using it is:-
Then we can use (for address):-
Works fine! |
This worked for me. |
Here you will have to change the console log command to the following:
It's obvious, though just telling to make coding more faster :) |
The code is copied exactly, but it tells me that web3 is not defined. It is definitely installed - I've done the npm install and I have installed web3 manually via npm install [email protected]
Any ideas?
The text was updated successfully, but these errors were encountered: