Hey guys, I have been stuck for days on trying to call a simple contract from a React Dapp using Metamask and Ganache. Is there anyone here that would be willing to have a look at my code for a second and enlighten me?
Mar 10, 2020, 10:16 AM
Check the dapp university tutorial called marketplace
Or read the drizzle docs
Mar 10, 2020, 10:17 AM
Thanks I’ll look into it
Is there any quick way in the JS console to check whether my Dapp is finding the web3 injected by Metamask?
When I type web3.window in the console it says:
inpage.js:1 MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider
Mar 10, 2020, 10:21 AM
Check the web3 docs.
You should correctly setup the blockchain provider, then get the network and finally create the instance of your contract
Mar 10, 2020, 10:24 AM
Yeah my metamask and ganache are set up properly
Too bad it’s not real ETH
Mar 10, 2020, 10:28 AM
This might be your solution
https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8
Basically you need to enable metamask explicitly by
await ethereum.enable();
https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8
Basically you need to enable metamask explicitly by
await ethereum.enable();
If not, you might wanna share some code snippet
Mar 10, 2020, 10:30 AM
Post code snippet
Mar 10, 2020, 10:36 AM
Hmm I thought this change hadn’t been implemented yet?
Currently my index.js file only contains the following:
var Web3 = require('web3');
console.log(Web3.window);
var Web3 = require('web3');
console.log(Web3.window);
Mar 10, 2020, 10:41 AM
It has been, for a long time it's live
The other changes were canceled but not this one
Mar 10, 2020, 10:42 AM
When I run it my console says: undefined
Mar 10, 2020, 10:42 AM
Pretty sure it's window.web3
Not the other way around
Mar 10, 2020, 10:43 AM
Oh that actually works, cool
Mar 10, 2020, 10:43 AM
Window is the default config object of browser's DOM where metamask injects web3
Thanks for confirming
For other curious fellas, metamask team wanted to remove automatic state change triggers from the extension but canceled because it would have caused lot of breaking changes
Mar 10, 2020, 10:46 AM
I’m trying this out right now, but before I move on — how do you insert these nice code snippets in Telegram?
Mar 10, 2020, 10:59 AM
embed in `
We have the entire markdown support here
https://sourceforge.net/p/telegram/wiki/markdown_syntax/
https://sourceforge.net/p/telegram/wiki/markdown_syntax/
Mar 10, 2020, 11:02 AM
like this?
sweeeet
Mar 10, 2020, 11:05 AM