4

I'm testing out Metamask under Chrome. I see that current Metamask (version 4.5.3) injects web3 version 0.20.3. Since web3 has a long history of volatile API, I would prefer to always stick to a specific version (possibly 1.0), independently of the one provided by Metamask.

In my understanding of how Metamask works, this should not be possible and, indeed, I've found nothing googling out this issue. Anyway, I wanted to ask the community, maybe I'm overlooking something.

Thanks.

1 Answer 1

7

Yes, you can use whatever version of web3 you want.

Just include the relevant <script> tag, and then do:

web3 = new Web3(web3.currentProvider);

This is how you should always use MetaMask. See, e.g., https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md and https://github.com/ethereum/wiki/wiki/JavaScript-API#adding-web3.

7
  • 1
    It's also worth noting that currently MetaMask does not support web3 1.0 or later. github.com/MetaMask/metamask-extension/issues/3639
    – DanF
    Apr 6, 2018 at 3:55
  • Good point, thanks @DanF. From my experience, it's only event subscription that don't work. (I suppose other kinds of subscriptions would have the same problem.)
    – user19510
    Apr 6, 2018 at 7:03
  • "Just include the relevant <script> tag, and then do" ... I'm a bit of a javascript noob, but what is "the relevant <script> tag" here exactly? May 15, 2018 at 20:16
  • 1
    <script src="/path/to/the/web3.js/you/want/to/use"></script>
    – user19510
    May 15, 2018 at 20:17
  • Thank you for a swift reply. With that line of code you suggest I can "bundle" the web3 version I like (choose web3.min.js version 1.0). But it is not clear to me how I can verify that my client side code is actually using the bundled version? Can I print out the version, for example? May 15, 2018 at 21:43

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.