question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Metamask / Mist / Parity Support

See original GitHub issue

As you mention in the readme, this library intends to include:

Complete functionality for all your Ethereum needs

If this is the case, one very common use case is have support Metamask (and even Mist / Parity). Is this feature on the roadmap? If not, is it worth attempting to implement?

As far as I know, it seems like it shouldn’t be too complicated, but obviously we don’t want to include web3 as a dependency, so we should somehow interact with the injected web3.currentProvider directly; https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
ricmoocommented, Jan 17, 2018

This should be good to go now. See https://github.com/ethers-io/ethers.js/commit/67bb0b7f93eee4c435555bcc3fe5eeda6614afc1.

Here is a modified version of the Metamask documentation for you to use ethers.js instead of using web3.

window.addEventListener('load', function() {

  // Checking if Web3 has been injected by the browser (Mist/MetaMask/EthersWallet)
  if (typeof web3 !== 'undefined') {
    // Use Mist/MetaMask's provider
    provider = new ethers.providers.Web3Provider(web3.currentProvider);
    signer = provider.getSigner();
  } else {
    console.log('No web3? You should consider trying MetaMask!')
    // Allow read-only access to the blockchain if no Mist/Metamask/EthersWallet
    provider = ethers.providers.getDefaultProvider();
  }

  // Now you can start your app & access the ethers provider and signer freely:
  startApp()
})
4reactions
ricmoocommented, Nov 14, 2017

The reasons to use BN are:

  1. It is already required by the elliptic curve libraries, so rather than using multiple Big Number libraries, we consolidate on the one that would be far too difficult and dangerous to remove
  2. BigNumber.js used in web3 is not actually BigNumber.js, but a fork of it, with several changes, and is not actively maintained and does not get bug fixes
  3. BigNumber is a decimal library, not an integer library, so it does not accurately reflect the operations required in Ethereum and its use can disregard underflow

The custom signer should instead of overriding sign, could instead override sendTransaction, which would give you the opportunity to intercept signing. This is how ethers.io creates a custom signer as well as the ethers-cli TestRPC wrappers. I haven’t had time to get a simple Custom Signer for MetaMask together, but I will try this week. The ethjs library is a thin wrapper around several ethers.js functions and cut and paste of some web3 functions. The easiest way to do what you wish is to extend the JsonRpcProvider, and override the send function to pass the calls off to the web3.sendAsync instead of call make a request to the network.

Sorry, I have 4 projects I’m trying to catch up on (ethers.js, the firefly hardware wallet, Ethers Wallet and ethers.io) but am hoping to get at least a cookbook entry this week on how to create a custom signer that bridges into Metamask. We certainly need to add more hours in a day… 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

ICO For Beginners - Add Token in MEW, Parity, Mist, MetaMask
In this video I show you how simple it is to add a Token to your wallet. This video will be helpful for...
Read more >
Using MetaMask and other wallets | Ethereum Cookbook
MetaMask, Mist, and MyCrypto are some of the popular wallets in the ... You can now use MetaMask with all supported websites for...
Read more >
Metamask Vs Parity. Which browser extension is good to ...
I have two options available Metamask and Parity. Are there any other better options available to access DAPP from web browser?
Read more >
Should I be using Mist or Parity? : r/ethereumnoobies - Reddit
I've tried both, and they seem to have different strengths and weaknesses. What are others using? Do most people just not run their...
Read more >
Mist Migration Patterns - Marc Garreau - Medium
Mist Browser and Ethereum Wallet are no longer supported. For the context around this decision, see this blog post. The Mist team strongly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found