dappuniversity / token_sale

Code Your Own Cryptocurrency & ICO on Ethereum | Tutorial
406 stars 387 forks source link

web3 not connect to meta mask #24

Open deepprajapati18 opened 5 years ago

deepprajapati18 commented 5 years ago

Screenshot from 2019-05-23 17-59-34

officialfrancismendoza commented 5 years ago

Came across a similar problem. I tried uninstalling and reinstalling Ganache, because for a separate project, I had a nonce mismatch which prevented me from making any transactions at all. See if that works.

EDIT: At roughly 5:59:00 in the video tutorial, Greg explains that the error is caused when an object parameter is expected and a null value is being passed instead. Also be sure that, if you are using his original code, you downgrade to Truffle v4.1.4 and Solidity v0.4.24

Madeindreams commented 4 years ago

@fmendoz7

I stumble on this as well. Maybe at the time the video was made the MetaMask connection procedure was not the same. You can look at my pull request that is adding the missing code for MetaMask to connect. However this code will no longer be valid after November 2020 and you will see a warning in the browser dev console about it. This is something I plan on doing to keep my project working after that date. I suspect that the web.3.js and truffle-contract.js will have to be updated as well. I have updated the code to solidity v0.5.16, so this might also change thing a little but I will PR when done and tested.

D-200021 commented 3 years ago

I am getting same error.please can anyone help me please !!

AnthonyJamez12 commented 3 years ago

Jan Kwaitkowski helped me with this issue. I added the function below between the tokensAvailable: 750000, and init: function() { at the top of the app.js file.

initMetaMask: function() {

async function enableUser() { const accounts = await ethereum.enable(); const account = accounts[0]; App.account = account; } enableUser(); },

and this function at the end of app.js

$(function() { $(window).load(function() { App.initMetaMask(); App.init(); })