Getting Started | MetaMask Docs (2024)

To develop for MetaMask, install MetaMask in the browser of your choice on your development machine. Download here (opens new window).

A quick note...

This guide assumes intermediate knowledge of HTML, CSS, and JavaScript.

Once MetaMask is installed and running (make sure you back up your Secret Recovery Phrase), you should find that new browser tabs have a window.ethereum object available in the developer console.This is how your website will interact with MetaMask.

You can review the full API for that object here.Note that over the course of 2020, we introduced significant changes to this API, and we recommend that you refer to its documentation.

# Basic Considerations

# Web3 Browser Detection

To verify if the browser is running MetaMask, copy and paste the code snippet below in the developer console of your web browser:

if (typeof window.ethereum !== 'undefined') { console.log('MetaMask is installed!');}

You can review the full API for the window.ethereum object here.

# Running a Test Network

In the top right menu of MetaMask, select the network that you are currently connected to. Among several popular defaults, you'll find Custom RPC and Localhost 8545. These are both useful for connecting to a test blockchain, like ganache (opens new window). You can quickly install and start Ganache if you have npm installed with npm i -g ganache-cli && ganache-cli.

Ganache has some great features for starting your application with different states. If your application starts with the -m flag, you can feed it the same seed phrase you have in your MetaMask, and the test network will give each of your first 10 accounts 100 test ether, which makes it easier to start work.

Since your seed phrase has the power to control all your accounts, it is probably worth keeping at least one seed phrase for development, separate from any that you use for storing real value. One easy way to manage multiple seed phrases with MetaMask is with multiple browser profiles, each of which can have its own clean extension installations.

# Resetting Your Local Nonce Calculation

If you're running a test blockchain and restart it, you can accidentally confuse MetaMask because it calculates the next noncebased on both the network state and the known sent transactions.

To clear MetaMask's transaction queue, and effectively reset its nonce calculation, you can use the Reset Account button in Settings (available in the top-right identicon menu).

# Detecting MetaMask

If you want to differentiate MetaMask from other Ethereum-compatible browsers, you can detect MetaMask using ethereum.isMetaMask.

# User State

Currently there are a few stateful things to consider when interacting with this API:

  • What is the current network?
  • What is the current account?

Both of these are available synchronously as ethereum.networkVersion and ethereum.selectedAddress.You can listen for changes using events too, see (the API reference).

# Connecting to MetaMask

"Connecting" or "logging in" to MetaMask effectively means "to access the user's Ethereum account(s)".

You should only initiate a connection request in response to direct user action, such as clicking a button.You should always disable the "connect" button while the connection request is pending.You should never initiate a connection request on page load.

We recommend that you provide a button to allow the user to connect MetaMask to your dapp.Clicking this button should call the following method:

ethereum.request({ method: 'eth_requestAccounts' });

Example:

    This promise-returning function resolves with an array of hex-prefixed Ethereum addresses, which can be used as general account references when sending transactions.

    Over time, this method is intended to grow to include various additional parameters to help your site request everything it needs from the user during setup.

    Since it returns a promise, if you're in an async function, you may log in like this:

    const accounts = await ethereum.request({ method: 'eth_requestAccounts' });const account = accounts[0];// We currently only ever provide a single account,// but the array gives us some room to grow.

    Example:

      # Choosing a Convenience Library

      Convenience libraries exist for a variety of reasons.

      Some of them simplify the creation of specific user interface elements, some entirely manage the user account onboarding, and others give you a variety of methods of interacting with smart contracts, for a variety of API preferences, from promises, to callbacks, to strong types, and so on.

      The provider API itself is very simple, and wrapsEthereum JSON-RPC (opens new window)formatted messages, which is why developers usually use a convenience library for interactingwith the provider, like ethers (opens new window), web3.js (opens new window),truffle (opens new window), Embark (opens new window), or others. From those tools,you can generally find sufficient documentation to interact with the provider, without reading this lower-level API.

      Getting Started | MetaMask Docs (2024)

      FAQs

      Is MetaMask legit and safe? ›

      MetaMask wallet is a legit and safe crypto wallet with a strong reputation and additional safety features. For users looking for an extra level of security, we would recommend connecting it to a hardware wallet.

      How does MetaMask make money? ›

      Does MetaMask make money from this? MetaMask receives a 1% fee on every transaction from providers, similar to when you buy crypto using MetaMask. Yes. Since selling your ETH to the preferred provider occurs on Ethereum Mainnet, you'll need to pay a gas fee in ETH.

      How does MetaMask work? ›

      Overview. MetaMask allows users to store and manage account keys, broadcast transactions, send and receive Ethereum-based cryptocurrencies and tokens, and securely connect to decentralized applications through a compatible web browser or the mobile app's built-in browser.

      Who owns MetaMask? ›

      The new technology is being built by Special Mechanisms Group (SMG), a blockchain infrastructure firm that MetaMask owner Consensys purchased last year.

      Can I withdraw money from MetaMask? ›

      To withdraw fiat money from MetaMask to your account, follow these steps: Transfer to a Crypto Exchange: Send your MetaMask crypto, like ETH, to an exchange (e.g., Binance or Coinbase). Sell the Crypto: On the exchange, sell your crypto for fiat money (USD, EUR, etc.).

      What if I got scammed on MetaMask? ›

      Create a new MetaMask wallet on the new browser, browser profile, or mobile device. Write down the Secret Recovery Phrase in the correct order and store it someplace safe. Never give it to anyone. Go back to the compromised account and send any remaining funds to the newly created account.

      How much does it cost to use MetaMask? ›

      The MetaMask transaction fee of 0.875% Gas on the destination network, which is generally covered by the bridge provider. Fees to liquidity providers and validators, who relay transactions across networks. Price impact, which relates to available liquidity and how the bridge will affect it.

      How do I get paid from MetaMask? ›

      To sell your crypto for cash:
      1. Connect your MetaMask wallet to portfolio.metamask.io.
      2. Click the “Sell” tab to get started.
      3. Select your region.
      4. Select the crypto token and network you want to sell from (example: ETH on Ethereum)
      5. Select fiat account destination available in your location(e.g.: bank account or PayPal balance)

      Why can't I sell my crypto on MetaMask? ›

      Whilst we want to make MetaMask's features accessible to as many people around the world as possible, selling crypto in MetaMask is not universally available. This is because the companies we partner with cannot operate in every jurisdiction, as their operations are affected by varying laws and regulations.

      What is the disadvantage of MetaMask? ›

      What are the disadvantages of MetaMask? MetaMask is a hot wallet. That means it's connected to the internet at all times, which increases the security risk for your crypto. Unless you're trading, it's best to store your keys in an offline wallet.

      How to use MetaMask for beginners? ›

      Input MetaMask into the search bar.
      1. Either click 'Get' or tap on the name of the app to see more details. Complete the usual App Store download confirmation process.
      2. Once installed, open the app and follow the prompts to create your wallet.
      3. Back up your Secret Recovery Phrase somewhere safe and offline!
      6 days ago

      Is MetaMask free? ›

      Yes, MetaMask is a free browser plugin that works with many current browsers. Users should only download the extension from a trusted source.

      Do people still use MetaMask? ›

      MetaMask reported passing 10 million monthly active users in August 2021. MetaMask allows users to self-custody and transact their crypto through a browser extension and a mobile app.

      Do you own your crypto on MetaMask? ›

      Crypto wallets like MetaMask are called self-custodial for this reason: You are the custodian and the only one who can access your private keys. There is no other custodian required to give you permission to control your assets, so there is nobody who can prevent you from interacting with them.

      What network does MetaMask use? ›

      Transactions made using MetaMask are registered on Ethereum blockchain and are publicly available. If someone knows your account address, they can see the transaction is made by you because accounts on the Ethereum network are pseudonymous.

      How do I know if MetaMask is legit? ›

      MetaMask will never pop up without you initiating a transaction. This means you need to click on some kind of button on a connected dapp for the genuine MetaMask to respond. If something appears as soon as you enter a site, or just randomly, it's likely a scam.

      Is MetaMask token real or fake? ›

      Here's some things to look out for when deciding whether or not to trust a token: Does the token appear in MetaMask when you have token detection turned on? If it doesn't, it means the token is absent from the trusted tokens lists that the token detection feature uses. It may therefore be untrustworthy.

      Is MetaMask safer than Coinbase? ›

      For a broader, more versatile cryptocurrency management tool, Coinbase Wallet will serve better. Security and Privacy: Those prioritizing high security and privacy might lean towards Metamask because of its decentralized nature and local storage of private keys.

      Is it safe to store money on MetaMask? ›

      MetaMask provides a secure environment for storing your cryptocurrency assets; however, it's generally recommended to use hardware wallets for storing large amounts of cryptocurrency. Hardware wallets offer an extra layer of physical security by keeping your private keys offline.

      Top Articles
      Best Burial & Life Insurance For 87 Year Olds In 2024
      How get a Master Ball in Pokémon Go
      Walgreens Harry Edgemoor
      My E Chart Elliot
      Citibank Branch Locations In Orlando Florida
      Mcfarland Usa 123Movies
      Undergraduate Programs | Webster Vienna
      Matthew Rotuno Johnson
      Pollen Count Central Islip
      No Credit Check Apartments In West Palm Beach Fl
      2016 Hyundai Sonata Price, Value, Depreciation & Reviews | Kelley Blue Book
      Slushy Beer Strain
      Med First James City
      Diesel Mechanic Jobs Near Me Hiring
      Xxn Abbreviation List 2023
      Po Box 35691 Canton Oh
      1773X To
      Phoebus uses last-second touchdown to stun Salem for Class 4 football title
      Babbychula
      Evil Dead Rise Showtimes Near Pelican Cinemas
      Like Some Annoyed Drivers Wsj Crossword
      About My Father Showtimes Near Copper Creek 9
      All Obituaries | Verkuilen-Van Deurzen Family Funeral Home | Little Chute WI funeral home and cremation
      Move Relearner Infinite Fusion
      Used Patio Furniture - Craigslist
      Craigslist Dubuque Iowa Pets
      A Christmas Horse - Alison Senxation
      Black Lion Backpack And Glider Voucher
      Tracking every 2024 Trade Deadline deal
      Kuttymovies. Com
      Our 10 Best Selfcleaningcatlitterbox in the US - September 2024
      Elanco Rebates.com 2022
      JD Power's top airlines in 2024, ranked - The Points Guy
      Autozone Locations Near Me
      D3 Boards
      19 Best Seafood Restaurants in San Antonio - The Texas Tasty
      Stafford Rotoworld
      Td Ameritrade Learning Center
      Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
      1v1.LOL Game [Unblocked] | Play Online
      Adam Bartley Net Worth
      Jack In The Box Menu 2022
      M Life Insider
      Shoecarnival Com Careers
      Love Words Starting with P (With Definition)
      BCLJ July 19 2019 HTML Shawn Day Andrea Day Butler Pa Divorce
      Ehc Workspace Login
      Sky Dental Cartersville
      Marine Forecast Sandy Hook To Manasquan Inlet
      Raley Scrubs - Midtown
      Vcuapi
      Island Vibes Cafe Exeter Nh
      Latest Posts
      Article information

      Author: Edwin Metz

      Last Updated:

      Views: 5661

      Rating: 4.8 / 5 (58 voted)

      Reviews: 89% of readers found this page helpful

      Author information

      Name: Edwin Metz

      Birthday: 1997-04-16

      Address: 51593 Leanne Light, Kuphalmouth, DE 50012-5183

      Phone: +639107620957

      Job: Corporate Banking Technician

      Hobby: Reading, scrapbook, role-playing games, Fishing, Fishing, Scuba diving, Beekeeping

      Introduction: My name is Edwin Metz, I am a fair, energetic, helpful, brave, outstanding, nice, helpful person who loves writing and wants to share my knowledge and understanding with you.