MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.7k stars 4.79k forks source link

No more interaction between my website and Metamask #1031

Closed olivier1977 closed 7 years ago

olivier1977 commented 7 years ago

Since the last update of metamask, when I want to start a transaction from my website (so not directly via opening the plugin, but by hitting an OK button on my site), the transaction isn't triggered in metamask. Nothing happens. Normally it should trigger the standard transaction confirmation notification where I still had to manuay accept or reject (as shown in the picture). Now no more notification comes up and my plugin isn't triggered. Has something changed in the way metamask interacts since the last release(s)?

I didn't change anything in my coding and last Thursday (12-1) it worked just fine (although only over a 4G connection, not wifi).

Anyone please help!

image

danfinlay commented 7 years ago

Things have changed in the last update, but we haven't seen this bug yet.

To find the bug, the most helpful thing would be a link to your dapp, so we could replicate it ourselves.

If you can't give us a link to the dapp, you'll have to find the source yourself. We have a document on getting logs from metamask, and there are a few places you might need to look for errors.

danfinlay commented 7 years ago

@olivier1977 you sent me the .js file but no .html to go with it. It would really help to have the whole application. I'm not about to go rewrite your UI so I can test this code.

kumavis commented 7 years ago

@olivier1977 you need to provide the whole thing - you are just giving us pieces. Is the project available on github?

kumavis commented 7 years ago

@olivier1977 We are not available to volunteer our time on closed source projects. If you need help on your closed source project we can provide you with consulting rates.

If you are encountering a bug in MetaMask we can attempt to diagnose based on errors from the app console and the background console. Here's how: https://github.com/MetaMask/faq/blob/master/LOGS.md

kumavis commented 7 years ago

Closing this until you provide any of the following: (1) a git repo with build instructions (2) a link to a published version of the app (3) app and background logs (4) intention to hire for consulting services

danfinlay commented 7 years ago

Yeah, I verified, this still isn't enough to run the application. :(

danfinlay commented 7 years ago

We're still happy to help if you can help us reproduce the issue, @olivier1977!

olivier1977 commented 7 years ago

Thanks for your responses so far guys, I am not unwilling to share things, just not so technical, that's why I just send these 2 files. I'll ask my team how we can share the lot you need. the site is running on www.oursurance.nl. Do you guys have an example of another site using metamask extension for interacting with ethereum (or a custom RPC) for setting up smart contract and sending messages to the smart contract through metamask? really appreciate it!

kind regards,

Olivier

On 19 January 2017 at 19:54, Dan Finlay notifications@github.com wrote:

We're still happy to help if you can help us reproduce the issue, @olivier1977 https://github.com/olivier1977!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MetaMask/metamask-plugin/issues/1031#issuecomment-273864527, or mute the thread https://github.com/notifications/unsubscribe-auth/AXzNAeUpMqvBpSCwvYA7ZdVVg7ofyTZ2ks5rT7F_gaJpZM4LoIeC .

-- ir. Olivier Rikken MBA 06 11394292

danfinlay commented 7 years ago

Oh, that site link is what we wanted. Exploring now...

danfinlay commented 7 years ago

I found your bug. On line 3 of your javascript, you're checking for the injected web3's provider instead of an injected web3:

// this:
if(typeof window.web3.currentProvider !== 'undefined')

// should be this:
if(typeof window.web3 !== 'undefined')

As described in our FAQ for developers: https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#partly_sunny-web3---ethereum-browser-environment-check

danfinlay commented 7 years ago

Oh actually, that's ok, the problem is you're over-writing the global web3 that we inject on line 1:

var web3 = new Web3();

You shouldn't do that until you've checked and there is no MetaMask.

olivier1977 commented 7 years ago

Thanks!!!!

Olivier Rikken +316 113 94 292

Op 19 jan. 2017 om 20:16 heeft Dan Finlay notifications@github.com het volgende geschreven:

I found your bug. On line 3 of your javascript, you're checking for the injected web3's provider instead of an injected web3:

// this: if(typeof window.web3.currentProvider !== 'undefined')

// should be this: if(typeof window.web3 !== 'undefined') As described in our FAQ for developers: https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#partly_sunny-web3---ethereum-browser-environment-check

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

olivier1977 commented 7 years ago

Thanks once again!

Olivier Rikken +316 113 94 292

Op 19 jan. 2017 om 20:23 heeft Dan Finlay notifications@github.com het volgende geschreven:

Oh actually, that's ok, the problem is you're over-writing the global web3 that we inject on line 1:

var web3 = new Web3(); You shouldn't do that until you've checked and there is no MetaMask.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

kumavis commented 7 years ago

@olivier1977 something like this -- will update the FAQ

var provider;
if (window.web3.currentProvider) {
  provider = window.web3.currentProvider;
} else {
  provider = new web3.providers.HttpProvider("http://37.139.8.195:8545");
}
var web3 = new Web3(provider);

Edit: actually I think this wont work bc of js hoisting Edit: tested - it works, hoisting is not an issue

Note that web3 needs to be declared inside the onload function to avoid overwriting window.web3. This is a side effect of javascript top level scope.

olivier1977 commented 7 years ago

Guys, thank you so much, thinks look like they work again. You're the best!

ZaraRaja commented 3 years ago

I found your bug. On line 3 of your javascript, you're checking for the injected web3's provider instead of an injected web3:

// this:
if(typeof window.web3.currentProvider !== 'undefined')

// should be this:
if(typeof window.web3 !== 'undefined')

As described in our FAQ for developers: https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#partly_sunny-web3---ethereum-browser-environment-check

// Modern DApp Browsers if (window.ethereum) { web3 = new Web3(window.ethereum); try { window.ethereum.enable().then(function() { // User has allowed account access to DApp... }); } catch(e) { // User has denied account access to DApp... } } // Legacy DApp Browsers else if (window.web3) { web3 = new Web3(web3.currentProvider); } // Non-DApp Browsers else { alert('You have to install MetaMask !'); }

ZaraRaja commented 3 years ago

Try this