GithubHelp home page GithubHelp logo

gravitylabllc / metamask-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metamask/metamask-sdk

0.0 0.0 0.0 185.82 MB

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.

Home Page: https://metamask.io/sdk/

License: Other

Shell 1.09% JavaScript 17.39% Ruby 0.76% C 0.30% Objective-C 0.75% Java 2.41% Go 0.20% TypeScript 72.48% CSS 1.59% Objective-C++ 0.37% HTML 1.54% Vue 0.82% Dockerfile 0.03% SCSS 0.26%

metamask-sdk's Introduction

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:

Features

  • Session persistence
  • Multi Provider (Let user choose between browser extension and mobile wallet)
  • Wagmi Hook Integration (alpha)
  • i18n throuhg Modal customization
  • smart contract library ( upcoming )

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

Web (d)apps

Follow example on:

React Native

We recommend using RN v0.71.4 or higher otherwise you may encounter significant performance issues on Android.

Follow example on:

NodeJS

import { MetaMaskSDK } from '@metamask/sdk';
const MMSDK = new MetaMaskSDK({
  dappMetadata: {
    name: 'NodeJS example',
  }
});
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);
  });

Electron

Follow example on:

SDK Options

You can find the full interface in sdk.ts file but here are the useful options:

  • checkInstallationImmediately: boolean (default: false) - If true, the SDK will check if MetaMask is installed on the user's browser and send a connection request. If not it will prompt the user to install it. If false, the SDK will wait for the connect method to be called to check if MetaMask is installed.

  • useDeeplink: boolean (default: false) - If true, the SDK will use deeplinks to connect with MetaMask Mobile. If false, the SDK will use universal links to connect with MetaMask Mobile.

  • shouldShimWeb3: boolean (default: false) - If true, the SDK will shim the window.web3 object with the provider returned by the SDK (useful for compatibility with older browser).

  • enableDebug: boolean (default: true) - Send anonymous analytics to MetaMask to help us improve the SDK.

  • modals: see nodejs example to customize or translate each of the displayed modals.

Contributing

Please see our contributing guidelines for more information.

metamask-sdk's People

Contributors

abretonc7s avatar andreahaku avatar andrepimenta avatar christopherferreira9 avatar gudahtt avatar guibibeau avatar jluque0101 avatar m1heng avatar mehmettaskiner avatar mrtenz avatar omridan159 avatar sethkfman avatar ziad-saab avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.