MetaMask / mascara

(beta) Add MetaMask to your dapp even if the user doesn't have the extension installed
Other
173 stars 29 forks source link

How to open MM/Mascara when the pop-up window has been closed #11

Open sulliwane opened 6 years ago

sulliwane commented 6 years ago

Hello,

I'm wondering how to open the MM/Mascara pop up after it has been closed?

I would like a user who don't have MM plugin installed in the browser to still be able to press a button on my website ("open MM") and it would pop up the mascara window, letting the user interact with MM (switch network etc...)

Simply opening a new tab pointing at "wallet.metamask.io" doesn't seem to have the same effect as the magic "pop up" window that shows up I don't know how... :)

Many thanks!

frankiebee commented 6 years ago

@sulliwane popup's can only be opened due to a user interaction eg.: click

sulliwane commented 6 years ago

thank you @frankiebee for your reply. That's precisely what I'm trying to do, let the user click on a button (on my frontend) so it opens the Mascara popup...

Right now, only when calling a wallet function will it open mascara:

import tokenJSON from 'token.json'
import metamask from 'metamascara'
import EthJs from 'ethjs'
const ethereumProvider = metamask.createDefaultProvider()
const ethjs = new EthJs(ethereumProvider)
const tokenContract = ethjs.contract(tokenJSON.abi, tokenJSON.unlinked_binary, { from: accounts[0] }).at(tokenJSON.networks[42].address)
tokenContract.transfer(addr, 10)  //  <-- this will open the pop-up, but as soon as the user ACCEPT the transaction, the pop-up is closed, and I have no way to see mascara (if I don't have the plugin installed)

As soon as my user ACCEPT the transaction (a transfer or whatever that requires him to sign something with MM) then the pop-up is closed !!

Is there any way to open mascara, WITHOUT sending a transaction signing request to my user (just plain "open") ?

I'm not sure if I'm clear :)

Thanks