While using MetaMask, adding Web3 to a Javascript program displays the following message in the Chrome console: "MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider"

Should I continue creating a website that requires MetaMask, if Web3 will be deprecated in the near future?

Is there a workaround, or is there another extension that allows Javascript to interact with Ethereum in the Chrome browser?

3 Answers 3


Sorry for the useless warning message. The path forward for now is to always use web3.currentProvider. The web3 global will still exist, it simply won't have any methods on it, so as long as you're following our guide on detecting and initializing your own web3, you should be fine.

  • Please confirm that if I only use the web3 object created by "window.web3 = new Web3(web3.currentProvider)", then my code will not become useless.
    – Tester
    Sep 1, 2017 at 22:42
  • As long as you imported that Web3 class, and are including it with your own code. Don't rely on an injected Web3 class, just the web3.currentProvider object.
    – DanF
    Sep 2, 2017 at 2:46
  • Please confirm that I don't have to do anything other than have the user logged into MetaMask, and create a web3 object in Javascript with the following command: "window.web3 = new Web3(web3.currentProvider)". Confirm that I don't have to import any other classes, or do anything else.
    – Tester
    Sep 2, 2017 at 14:10
  • I can't confirm that. I just said you need to import your own Web3 instance, or equivalent abstaction library, like ethjs.
    – DanF
    Sep 3, 2017 at 22:24
  • Please indicate where the specific instructions can be found to "import your own Web3 instance, or equivalent abstaction library". In your first response to this issue, you said "as long as you're following our guide, you should be fine". The guide that you provided a link to did not indicate that anything else needs to be downloaded or installed. You indicated that it was a "useless warning message". Now your inferring that my code will stop working if I don't perform some actions that are not documented anywhere. So please provide specific instructions, and not just a vague description.
    – Tester
    Sep 4, 2017 at 2:55

DanF's answer is the correct answer, and should be accepted, but looking at the comments, I think there's some valuable context that might be missing, that I can add.

A typical dapp consists of a number of layers, which don't need to know much about the layers above or below them. Most dapps will use a library that provides a nice interface to the ethereum blockchain, such as Web3, truffle-contract or EthJS (although this is optional, and it's perfectly possible to write a dapp that doesn't use any of these libraries, and just uses lower-level interfaces). These libraries don't typically have the ability to access the blockchain directly (this is a slight lie - they often have helpers for local development, but it's close enough for most purposes), so need to have a low-level "provider" made available, that gives them access to the blockchain. MetaMask is such a provider.

In the early days, most dapp browsers (including MetaMask, Mist and Parity) worked by making a copy of Web3 available to dapps (by adding a web3 object to window), rather than making this provider available directly. Dapps that wanted to use other libraries, so needed to get at the underlying provider, would typically get hold of it with window.web3.currentProvider.

As time's gone on, it's become clear that even if you intend to use Web3 as your library of choice, it's a good idea to import Web3 into your dapp yourself (the same way you'd import any other library - Webpack or Parcel or SystemJS or Bower or plain ol' script tags pointing to a CDN), and initialise it with the provider from window.web3.currentProvider. This way, you always know what version of Web3 you're using, and aren't surprised by breaking API changes.

But if dapps are only using window.web3 to get at window.web3.currentProvider, then what's the point in including the rest of Web3 in window.web3? Not much. So MetaMask is planning (at some point) to change window.web3 from being a full copy of Web3, to just being a stub that provides currentProvider.

If you're still using the copy of Web3 provided by window.web3 at that point, then your code will no longer work. However, if you follow the instructions that DanF linked to to obtain a provider, and then follow the instructions for your library of choice from there on out, then it will work with current and future versions of MetaMask (as well as Parity and Mist, which I believe follow the same convention).

  • Amazing that no one provided SPECIFIC INSTRUCTIONS how to download the Web3 javascript include files. This post has received nothing but ambiguous answers with links to websites that require that you download a bunch of risky include files.
    – Tester
    Feb 12, 2018 at 0:29
  • Please provide a SIMPLE CONCISE explanation how to download just the necessary Javascript files, so MetaMask users won't have to worry that "at that point, your code will no longer work.". I sent an email to all the authors of MetaMask last week, and did not receive a single response. Dan F's domain was not even working. MetaMask seems like a risky extension to use.
    – Tester
    Feb 12, 2018 at 0:36
  • I didn't add those instructions deliberately, since most front-end projects I've worked on use a build tool like Webpack, Parcel, or Bower, so it would do more harm than good to provide instructions that wouldn't apply to everyone. But the simplest thing you could possibly do is to download the minified version of Web3 from github.com/ethereum/web3.js/raw/0.19.0/dist/web3.min.js, and add it to your HTML file with <script src="web3.min.js"></script>. If you're using a build tool, add the web3 module to your project in whatever way you would normally add a module.
    – James_pic
    Feb 12, 2018 at 15:23
  • Also, just to respond to your assertion that "MetaMask seems like a risky extension to use", note that all the Ethereum dapp browsers I know of work in precisely the same way. If you want to integrate with an alternative dapp browser, the way you do this is exactly the same. The only exception to this would be if you wanted to use infura.io, and skip the dapp browser entirely, but this is more work, and has security implications that you need to understand before you proceed any further (make sure you understand how the recent EtherDelta hack worked, before you go down that road).
    – James_pic
    Feb 12, 2018 at 15:35
  • James, thank you for your informative response. It is nice to finally have the web3 include file, in case MetaMask should suddenly require that it is added (which would cause many MetaMask users to have their scripts immediately fail).
    – Tester
    Feb 13, 2018 at 19:44

To answer my own question, it appears that you should NOT create a website that requires MetaMask.

The previous answerer (who apparently is the creator of MetaMask) contradicted himself. First, he said "Sorry for the useless warning message ... you should be fine". Then, after I relied on this answer and spent the entire weekend creating a website around the MetaMask extension, he said (in the comments above) "you need to import your own Web3 instance, or equivalent abstaction library, like ethjs". None of the MetaMask documentation describes how to do this.

Without specific, unambiguous instructions, I am very reluctant to release a website that could potentially have millions of dollars in transactions.

  • 3
    MetaMask is implementing the foundation-backed Ethereum provider protocol, to the fullest extent possible. The lack of documentation you see for MetaMask is really global to the space, because it's young and moving fast.
    – DanF
    Sep 4, 2017 at 6:56
  • While I am a developer on MetaMask, I'm not the only one, I didn't author that warning, I tried to help you. I've opened an issue for adding better docs around this, we'll try to add them soon. github.com/MetaMask/metamask-extension/issues/2014
    – DanF
    Sep 4, 2017 at 6:58
  • Please provide specific answers to these questions: 1. What date will MetaMask fail to work with the current instructions (without downloading an additional JS include file). 2. What JS include file needs to be included for MetaMask to work after that date, and what is its download URL. 3. Will the "window.web3 = new Web3(web3.currentProvider)" command work the same after including this new JS file. 4. Will all other instructions in your documentation work as described after including this new JS file. 5. Have you personally tested the answers given. 6. Are there any other caveats.
    – Tester
    Sep 4, 2017 at 11:51
  • 1. We do not have a firm deprecation date, we are waiting on web3 1.0 to be final, and so this warning maybe should not have been shown yet. 2. You don't need to include any JS file at all, the ethereumProvider provides all the functionality of web3, however it is not a user-friendly API (provider.sendAsync), nor is it well documented, and so most people will choose to import an abstraction like web3 or ethjs. 3. If you import the same version of Web3, yes. 4. Yes. 5. Yes. 6. I'll be writing an article for this soon.
    – DanF
    Sep 4, 2017 at 16:42
  • Your statement "You don't need to include any JS file at all" contradicted your previous reply "you need to import your own Web3 instance". Which is it? If I am better off importing a JS file, then please provide its download URL and confirm that you have tested it and that all existing code will work with it. If there is no need to import a JS file, then please change your reply when I asked "Please confirm that I don't have to do anything other than have the user logged into MetaMask, and create a web3 object in Javascript." Please give me a straight answer, its either one or the other.
    – Tester
    Sep 4, 2017 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.