Skip to content

gd-cho/metamask-detetor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetaMaskDetector


Detect MetaMask Inject Variable Ethereum.

Usage

import metamaskDetetor from "metamask-detetor";

function ethereumDetector = async () => {
  const ethereum = await metamaskDetetor();

  // switch network to ethereum network
  await ethereum.request({
        method: 'wallet_switchEthereumChain',
        params: [{ chainId: '0x1' }],
  });

  // Launch MetaMask Connect Request
  try {
    await ethereum.request({
      method: 'eth_requestAccounts'
    });
  } catch (error) {
    console.error(`User Reject Connect:${error.message}`);
  }
}
feed me: 0x3a64c43c24032DA32d422DB49a19052D1C584446

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published