• Stars
    star
    1,625
  • Rank 28,771 (Top 0.6 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mobile web browser providing access to websites that use the Ethereum blockchain

MetaMask logo

MetaMask

CI CLA

MetaMask is a mobile wallet that provides easy access to websites that use the Ethereum blockchain.

For up to the minute news, follow our Twitter or Medium pages.

To learn how to develop MetaMask-compatible applications, visit our Developer Docs.

MetaMask Mobile

Environment Setup

The code is built using React-Native and running code locally requires a Mac or Linux OS.

  • Install sentry-cli tools: brew install getsentry/tools/sentry-cli

  • Install Node.js version 16

    • If you are using nvm (recommended) running nvm use will automatically choose the right node version for you.
  • Install Yarn v1

  • Install the shared React Native dependencies (React Native CLI, not Expo CLI)

    • XCode version 14.2 or below
  • Install cocoapods by running:

sudo gem install cocoapods -v 1.12.1
  • Install Python version ^3.10
    • Note: M1 User might need to stay with version 3.10

Device Environment Setup

Android

  • Install Java. To check if Java is already installed, run:
  java -version
  • Install the Android SDK, via Android Studio.
    • MetaMask Only: To create production builds, you need to install Google Play Licensing Library via the SDK Manager in Android Studio.
  • Install the Android NDK (version 21.4.7075529), via Android Studio's SDK Manager.
    • Go to Settings > Appearance & Behavior > System Settings > Android SDK
      • Shortcut: Selecting More Actions > SDK Manager from the "Welcome to Android Studio" page will also bring you here.
    • Select SDK Tools tab
    • Check Show Package Details option below the tools list to show available versions
    • Locate NDK (Side-by-side) option in the tools list
    • Check NDK version 21.4.7075529
    • Locate CMake option in the tools list
    • Check CMake version 3.22.1
    • Click "Apply" or "OK" to download
  • Linux only:
    • Ensure that you have the secret-tool binary on your machine.
      • Part of the libsecret-tools package on Debian/Ubuntu based distributions.
  • Install the correct emulator
    • Follow the instructions at:
      • React Native Getting Started - Android (React Native CLI Quickstart -> [your OS] -> Android)
      • FYI: as of today (7/18/23) there is currently an issue when running detox on android 12 and 13 (API 32/33) which prevents the tests from running. The issue is, the tap() action is treated like a tapAndHold() action. See the open issue in wix/detox here
      • More details can be found on the Android Developer site
    • You should use the following:
      • Android OS Version: Latest, unless told otherwise
      • Device: Google Pixel 5
  • Finally, start the emulator from Android Studio:

iOS

  • Install the iOS dependencies
  • Install the correct simulator
    • iOS OS Version: Latest, unless told otherwise
    • Device: iPhone 12 Pro

Building Locally

  • Clone this repo:
git clone ...
cd metamask-mobile
  • MetaMask Only: Rename the .*.env.example files (remove the .example) in the root of the project and fill in the appropriate values for each key. Get the values from another MetaMask Mobile developer.
  • Non-MetaMask Only: In the project root folder run
  • If you intend to use WalletConnect v2 during your development, you should register to get a projectId from WalletConnect website and set the WALLET_CONNECT_PROJECT_ID value accordingly in .js.env file.
  cp .ios.env.example .ios.env && \
  cp .android.env.example .android.env && \
  cp .js.env.example .js.env
  • Non-MetaMask Only: Create an account and generate your own API key at Infura in order to connect to main and test nets. Fill MM_INFURA_PROJECT_ID in .js.env. (App will run without it, but will not be able to connect to actual network.)

  • Non-MetaMask Only: Fill MM_SENTRY_DSN in .js.env if you want the app to emit logs to your own Sentry project.

  • Install the app:

yarn setup # not the usual install command, this will run a lengthy postinstall flow
  • Then, in one terminal, run:
yarn watch

Android

yarn start:android

iOS

yarn start:ios

Build Troubleshooting

Unfortunately, the build system may fail to pick up local changes, such as installing new NPM packages or yarn linking a dependency. If the app is behaving strangely or not picking up your local changes, it may be due to build issues. To ensure that you're starting with a clean slate, close all emulators/simulators, stop the yarn watch process, and run:

yarn clean

# if you're going to `yarn link` any packages,
# do that here, before the next command

yarn watch:clean

# ...and then, in another terminal

yarn start:ios

# or

yarn start:android

If yarn link fails after going through these steps, try directly yarn adding the local files instead.

Debugging

First, make sure you have the following running:

  • yarn watch
  • Your Android emulator or iOS simulator
  • yarn start:android or yarn start:ios

Next, install the Flipper desktop app (verified working with v0.127.0)

  • Once Flipper is installed, configure your system as follows:
    • Install react-devtools: npm i -g [email protected]
    • Update Android SDK location settings by accessing Flipper's settings via the Gear Icon -> Settings
      • Example SDK path: /Users/<USER_NAME>/Library/Android/sdk

Finally, check that the debugger is working:

  • Open your emulator or simulator alongside the Flipper app
  • Flipper should auto-detect the device and the application to debug
  • You should now be able to access features such as Logs

Debugging Physical iOS devices

  • Debugging physical iOS devices requires idb to be installed, which consists of 2 parts
  • Install the two idb parts:
    1. brew tap facebook/fb & brew install idb-companion
    2. pip3.9 install fb-idb (This step may require that you install python3 via python -m pip3 install --upgrade pip)

Debug a website inside the WebView (in-app browser)

Android

  • Run the app in debug mode (for example, in a simulator)
  • Open Chrome on your desktop
  • Go to chrome://inspect/#devices
  • Look for the device and click inspect

iOS

  • Run the app in debug mode (for example, in a simulator)
  • Open Safari on your desktop
  • Go to the menu Develop -> [Your device] -> [Website]

You should see the console for the website that is running inside the WebView

Miscellaneous

Running Tests

Unit Tests

yarn test:unit

E2E Tests

Platforms

For both iOS and Android platforms, our chosen E2E test framework is Detox. We also utilize Appium for Android (wdio folder).

Test wallet

E2E tests use a wallet able to access testnet and mainnet. On Bitrise CI, the wallet is created using the secret recovery phrase from secret env var. For local testing, the wallet is created using the secret recovery phrase from the .e2e.env file.

Detox

All tests live within the e2e/specs folder.

iOS

Prerequisites for running tests:

  • Make sure to install detox-cli by referring to the instructions mentioned here.
  • Additionally, install applesimutils by following the guidelines provided here.
  • Before running any tests, it's recommended to refer to the iOS section above and check the latest simulator device specified under Install the correct simulator.
  • The default device for iOS is the iPhone 12 Pro and Android the Pixel 5. Ensure you have these set up.
  • Make sure that Metro is running. Use this command to launch the metro server:
yarn watch

You can trigger the tests against a release or debug build. It recommended that you trigger the tests against a debug build.

To trigger the tests on a debug build run this command:

For iOS

yarn test:e2e:ios:debug

and on Android:

yarn test:e2e:android:debug

If you choose to run tests against a release build, you can do so by running this command:

For iOS

yarn test:e2e:ios

and on Android:

yarn test:e2e:android

If you have already built the application for Detox and want to run a specific test from the test folder, you can use this command:

For iOS

yarn test:e2e:ios:debug:single e2e/specs/TEST_NAME.spec.js

and on Android:

yarn test:e2e:android:debug:single e2e/specs/TEST_NAME.spec.js

To run tests associated with a certain tag, you can do so using the --testNamePattern flag. For example:

yarn test:e2e:ios:debug --testNamePattern="Smoke"
yarn test:e2e:android:debug --testNamePattern="Smoke"

This runs all tests that are tagged "Smoke"

Appium

The appium tests lives within the wdio/feature folder.

By default the tests use an avd named Android 11 - Pixel 4a API 31, with API Level 30 (Android 11). You can modify the emulator and platform version by navigating to wdio/config/android.config.debug.js and adjusting the values of deviceName to match your emulator's name, and platformVersion to match your operating system's version. Make sure to verify that the config file accurately represents your emulator settings before executing any tests.

The sequence in which you should run tests:

create a test build using this command:

yarn start:android:qa

Then run tests using this command:

yarn test:wdio:android

If you want to run a specific test, you can include the --spec flag in the aforementioned command. For example:

yarn test:wdio:android --spec ./wdio/features/Onboarding/CreateNewWallet.feature

Changing dependencies

Whenever you change dependencies (adding, removing, or updating, either in package.json or yarn.lock), there are various files that must be kept up-to-date.

  • yarn.lock:
    • Run yarn setup again after your changes to ensure yarn.lock has been properly updated.
  • The allow-scripts configuration in package.json
    • Run yarn allow-scripts auto to update the allow-scripts configuration automatically. This config determines whether the package's install/postinstall scripts are allowed to run. Review each new package to determine whether the install script needs to run or not, testing if necessary.
    • Unfortunately, yarn allow-scripts auto will behave inconsistently on different platforms. macOS and Windows users may see extraneous changes relating to optional dependencies.

Architecture

To get a better understanding of the internal architecture of this app take a look at this diagram.

Storybook

We have begun documenting our components using Storybook. Please read the Documentation Guidelines to get up and running.

Other Docs

More Repositories

1

metamask-extension

🌐 🔌 The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
JavaScript
10,758
star
2

eth-phishing-detect

Utility for detecting phishing domains targeting Web3 users
TypeScript
1,091
star
3

snaps

Extend the functionality of MetaMask using Snaps
TypeScript
715
star
4

metamask-docs

Developer documentation for MetaMask
MDX
660
star
5

web3-provider-engine

A JavaScript library for composing Ethereum provider objects using middleware modules
JavaScript
585
star
6

faq

MetaMask FAQ and Guides
538
star
7

eth-sig-util

A collection of functions for signing and verifying data with Ethereum keys.
TypeScript
537
star
8

test-dapp

The sample dapp used for e2e testing and metamask-extension QA
JavaScript
456
star
9

contract-metadata

A mapping of ethereum contract addresses to broadly accepted icons for those addresses.
JavaScript
440
star
10

detect-provider

A tiny utility for detecting the MetaMask Ethereum Provider, or any Provider compliant with EIP-1193.
JavaScript
231
star
11

logo

A 3d take on the metamask logo, in browser, as a browserifyable module.
JavaScript
214
star
12

KeyringController

A module for managing groups of Ethereum accounts and using them.
TypeScript
183
star
13

metamask-sdk

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

mascara

(beta) Add MetaMask to your dapp even if the user doesn't have the extension installed
JavaScript
173
star
15

core

This monorepo is a collection of packages used across multiple MetaMask clients
TypeScript
172
star
16

providers

An Ethereum Provider that connects over a stream, as injected into websites by MetaMask
TypeScript
161
star
17

eth-json-rpc-middleware

Ethereum middleware for composing an Ethereum provider using json-rpc-engine. Intended to replace provider-engine
TypeScript
153
star
18

vault-decryptor

A web app for decrypting MetaMask vault data.
JavaScript
147
star
19

metamask-snaps-beta

Fork of MetaMask that supports plugins! Read the Wiki!
JavaScript
143
star
20

metamask-onboarding

A library to help onboard new MetaMask users
TypeScript
142
star
21

dapps

home.metamask.io website
JavaScript
135
star
22

eth-block-tracker

A JS module for keeping track of the latest Ethereum block by polling an ethereum provider
TypeScript
129
star
23

Add-Token

A simple web3 dapp that allows suggesting a token to users of compatible wallets like MetaMask.
JavaScript
127
star
24

json-rpc-engine

A tool for processing JSON RPC
TypeScript
125
star
25

template-snap-monorepo

TypeScript
113
star
26

eth-simple-keyring

A simple standard interface for a series of Ethereum private keys
TypeScript
113
star
27

legacy-web3-extension

An extension that adds MetaMask's legacy web3 API to your browser.
JavaScript
92
star
28

rpc-errors

Ethereum RPC Errors
TypeScript
90
star
29

browser-passworder

A simple browserifiable module for encrypting and decrypting JSON-serializable objects with a password.
TypeScript
86
star
30

eth-hd-keyring

A simple standard interface for an HD ethereum wallet.
TypeScript
81
star
31

eth-faucet

MetaMask's test faucet
JavaScript
71
star
32

eth-token-tracker

A JS module for tracking Ethereum token balances over block changes
JavaScript
71
star
33

extensionizer

A JS module for writing cross-browser extensions
JavaScript
66
star
34

eth-ledger-bridge-keyring

A wrapper around LedgerJS libraries, to support the KeyringController protocol used by MetaMask
TypeScript
66
star
35

post-message-stream

Sets up a duplex object stream over window.postMessage
TypeScript
51
star
36

template-snap

The official MetaMask Snaps template repository.
JavaScript
47
star
37

eth-json-rpc-infura

json-rpc-engine middleware for Infura's endpoints
TypeScript
47
star
38

extension-provider

A module for allowing a WebExtension to access the web3 provider from an installed MetaMask instance
JavaScript
46
star
39

metamask-android-sdk

MetaMask SDK for Android
Kotlin
44
star
40

TipButton

A set of tip button images for use with MetaMask
HTML
41
star
41

IPFS-Ethereum-Hackathon

Repo for hackathon submissions
40
star
42

metamask-ios-sdk

MetaMask SDK for iOS
Swift
39
star
43

website

The MetaMask website
JavaScript
39
star
44

brand-resources

MetaMask logo assets and brand guidelines
39
star
45

nonce-tracker

JavaScript
37
star
46

SIPs

Snaps Improvement Proposals
HTML
37
star
47

eth-trezor-keyring

A JS wrapper around Trezor Connect libraries, to support the KeyringController protocol used by MetaMask
TypeScript
37
star
48

snaps-cli

A CLI for developing MetaMask plugins.
TypeScript
36
star
49

Nextjs-Starter

TypeScript
35
star
50

key-tree

TypeScript
33
star
51

delegation-framework

The contracts that power the Delegation Framework
Solidity
33
star
52

mobile-provider

An Ethereum provider, as injected into websites by MetaMask Mobile
JavaScript
32
star
53

utils

Various JavaScript / TypeScript utilities of wide relevance to the MetaMask codebase.
TypeScript
30
star
54

rpc-cap

A module for adding an object-capabilities system to any JSON-RPC API as middleware for json-rpc-engine
JavaScript
30
star
55

api-specs

JavaScript
29
star
56

eth-json-rpc-filters

json-rpc-engine middleware implementing ethereum filter methods
JavaScript
29
star
57

etherscan-link

A library for generating Etherscan links
JavaScript
28
star
58

design-tokens

Design tokens to be used throughout MetaMask products
TypeScript
28
star
59

snaps-registry

A registry containing metadata about verified and blocked Snaps.
TypeScript
28
star
60

React-MetaMask-Login-Button

JavaScript
27
star
61

hd-seed-phrase-guesser

A tool for recovering ethereum accounts from mis-recorded seed phrases.
JavaScript
25
star
62

obs-store

A synchronous in-memory store for a single value
JavaScript
25
star
63

react-dapp-tutorial

Source code for the MetaMask Documentation's Dapp Tutorial using Vite + React
CSS
25
star
64

metamask-module-template

A simple template repository for starting new modules in the latest MetaMask fashion.
JavaScript
24
star
65

metamask-filecoin-developer-beta

The MetaMask Filecoin Developer Preview.
JavaScript
23
star
66

nft-tickets-workshop

React Dapp for selling ERC-721 NFT tickets
JavaScript
23
star
67

metamask-deeplinks

Simple web app to generate Metamask deeplinks on the fly
JavaScript
23
star
68

abi-utils

Lightweight utilities for encoding and decoding Solidity ABI
TypeScript
22
star
69

mesh-testing

Testbed for p2p metamask client
JavaScript
22
star
70

metamask-storybook

The Storybook for the MetaMask extension
JavaScript
20
star
71

test-snaps

TypeScript
20
star
72

metamask-improvement-proposals

A public space to discuss, evaluate, and implement improvements to the MetaMask Wallet API
19
star
73

eth-ipfs-browser-client

Ethereum browser client based on ipfs/libp2p
19
star
74

vite-react-ts-eip-6963

Discover Multi Injected Providers with EIP-6963 in a ViteJS using React + TypeScript
TypeScript
19
star
75

keyring-api

TypeScript
18
star
76

.github

MetaMask default GitHub community health files
18
star
77

eth-method-registry

A JS library for getting Solidity method data from a four-byte method signature
JavaScript
18
star
78

snap-simple-keyring

TypeScript
17
star
79

extension-port-stream

A module for creating a node style stream over a WebExtension port object.
TypeScript
17
star
80

contributor-docs

Guides, best practices, and everything needed to contribute to MetaMask repositories effectively.
JavaScript
17
star
81

mm-docs-v2

MetaMask developer documentation v2
JavaScript
15
star
82

snap-box

A box to start creating a snap with truffle
TypeScript
15
star
83

safe-event-emitter

An EventEmitter that isolates the emitter from errors in handlers
TypeScript
15
star
84

eth-gas-price-suggestor

A module for advising default gas prices, by analyzing recent successful transactions.
JavaScript
15
star
85

phishing-warning

A page to warn users about a suspected phishing site.
TypeScript
15
star
86

snaps-directory

Explore community-built Snaps to customize your web3 experience via our official directory.
TypeScript
14
star
87

Eth-Token-Sender

A simple single-page app for viewing an Ethereum token's balance and sending it.
JavaScript
14
star
88

legacy-web3

MetaMask's legacy window.web3
JavaScript
14
star
89

examples

A collection of examples and useful guides on how we think MetaMask can be used.
TypeScript
13
star
90

web3-dubai-mm-workshop

TypeScript
13
star
91

snaps-simulator

A hackathon project by @eriknson, @FrederikBolding, and @Mrtenz
TypeScript
12
star
92

menpo

DeFi Incident Database
JavaScript
12
star
93

zero-client

MetaMask ZeroClient and backing iframe service
JavaScript
12
star
94

action-publish-release

TypeScript
12
star
95

action-create-release-pr

TypeScript
11
star
96

smart-transactions-controller

TypeScript
11
star
97

metamask-desktop

🖥️ The MetaMask Desktop app is a companion app that improves the overall performance of the MetaMask Extension Flask build
TypeScript
11
star
98

metamask-eth-abis

Collection of smart contracts ABIs
TypeScript
10
star
99

object-multiplex

Simple stream multiplexing for objectMode.
TypeScript
10
star
100

react-sdk-linea-workshop

MetaMask SDK + Linea (Vite + React & TypeScript Workshop)
TypeScript
10
star