Hello, greetings
Useful for anyone reaching this section of the course where you have to edit and update ‘eth.js’ so that the game will interact with the deployed token contract in the Testnet (i.e. Ropsten). Making an update to what Filip has shown in the video lecture:
Inside eth.js, instead of having the code:
web3 = new Web3(web3.currentProvider);
ethereum.enable();
You can use:
web3 = new Web3(ethereum);
ethereum.request({ method: 'eth_requestAccounts' });
A simplified version on the updates that happened for the past 2 years
- ethereum.enable() is deprecated, see Metamask docs
- ‘ethereum’ object from Web3.js already provides a provider (Metamask no longer injects one like before)
Hope this is helpful to you.
With kind regards