Skip to content

Latest commit

 

History

History
57 lines (44 loc) · 2.94 KB

README.md

File metadata and controls

57 lines (44 loc) · 2.94 KB

MetaMask SDK

The MetaMask SDK enables developers to easily connect their dapps with a MetaMask wallet (Extension or Mobile) no matter the dapp environment or platform.

The MetaMask SDK is a library that can be installed by developers on their projects and will automatically guide their users to easily connect with a MetaMask wallet client. For instance, for dapps running on a desktop browser, the SDK will check if Extension is installed and if not it will prompt the user to install it or to connect via QR code with their MetaMask Mobile wallet. Another example, for native mobile applications, the SDK will automatically deeplink into MetaMask Mobile wallet to make the connection.

The MetaMask SDK instance returns a provider, this provider is the ethereum object that developers are already used to which is here. This provider will now be available for:

Getting Started

The following code examplifies importing the SDK into a javascript-based app. For other languages, check the sections bellow.

Install the SDK:

yarn add @metamask/sdk
or
npm i @metamask/sdk

Import the SDK (for possible parameters check this):

import { MetaMaskSDK } from '@metamask/sdk';
const MMSDK = new MetaMaskSDK({});
MMSDK.connect()
  .then((accounts) => {
    console.log('MetaMask SDK is connected', accounts);
    const ethereum = MMSDK.getProvider();
    const ethereum = sdk.getProvider();
    const balance = await ethereum.request({
      method: 'eth_getBalance',
      params: accounts,
    });

    console.debug(`account balance`, balance);
  })
  .catch((error) => {
    console.error(error);
  });

Follow the full documentation

Please access this to read the MetaMask SDK full documentation