web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

"Install MetaMask"

Open vporton opened this issue 4 years ago • 5 comments

Please display "Install MetaMask" link if MetaMask is missing in the browser.

vporton avatar Feb 19 '21 22:02 vporton

Please display "Install MetaMask" link if MetaMask is missing in the browser.

He,y we also needed "install metamask" option, and added the feature in a forked web3modal. You may look at that: https://github.com/blocklords/web3modal

Added a bit of documentation and screenshots of it.

Later will make a pull request, if they are agree.

SchneiderNejc avatar Feb 20 '21 13:02 SchneiderNejc

Ye this would be so awesome to add! It confusing to users to not present the option, our dapp we often onboard them via something like Formtaitc, Portis etc and then once they realise then all want to move over to MM and have to export keys etc.

Ideally we can drive them to MM and us ethe others a fallback.

Big one up from me on this issue being addreseed 👍🏻

jamesmorgan avatar Mar 12 '21 16:03 jamesmorgan

A quick workaround is to use a CSS Trick as below...

web3Modal = new Web3Modal({
        cacheProvider: true, // optional
        disableInjectedProvider: false,
        providerOptions,
      })
      installMetamask()
      ....
      
      
    function installMetamask() {
    if (!(window.web3 || window.ethereum)) {
      if ($('#installMetaMask').length < 1)
        $('.web3modal-modal-card').prepend('<div id="installMetaMask" class="cjAFRf web3modal-provider-wrapper"><a href="https://metamask.io/" target="_blank" class="cjAFRf web3modal-provider-container"><div class="jMhaxE web3modal-provider-icon"><img src="./assets/img/metamask.svg" alt="MetaMask"></div><div class="bktcUM sc-web3modal-provider-name mt-0">Install MetaMask</div><div class="eFHlqH web3modal-provider-description">Connect using browser wallet</div></a></div>')
    }
  }

argupta7 avatar Jun 02 '21 09:06 argupta7

Another workaround:

import  { providers } from 'web3modal';
if (!window.ethereum) {
  providerOptions['custom-metamask'] = {
    display: {
      logo: providers.METAMASK.logo,
      name: 'Install MetaMask',
      description: 'Connect using browser wallet'
    },
    package: {},
    connector: async () => {
      window.open('https://metamask.io')
      throw new Error('MetaMask not installed');
    }
  }
}

blabno avatar Jan 29 '22 19:01 blabno

Another workaround:

import  { providers } from 'web3modal';
if (!window.ethereum) {
  providerOptions['custom-metamask'] = {
    display: {
      logo: providers.METAMASK.logo,
      name: 'Install MetaMask',
      description: 'Connect using browser wallet'
    },
    package: {},
    connector: async () => {
      window.open('https://metamask.io')
      throw new Error('MetaMask not installed');
    }
  }
}

this is ingenious, thank you 👏 👏 👏

johnwwk avatar Sep 02 '22 10:09 johnwwk

With stable version 2.0.0 of Web3Modal now released, we are officially dropping support for version 1.x Due to this this issue/pr was marked for closing. It is highly recommended to upgrade as 2.x will be receiving further updates that will enable functionality for some of our newer sdks like auth and push as well as support for WalletConnect v2 (See this post about WalletConnect v1 being deprecated https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e)

If you need to continue using Web3Modal 1.x and require this feature/fix implemented, we suggest adding it via forking V1 branch.

xzilja avatar Jan 21 '23 14:01 xzilja