5

I am considering using ether.js instead of web3js. One of the factors I am considering is the integration with metamask.

Is there any support in ether.js to use metamask as wallet? If there isn't, will a simple decorator pattern wrapping around browserside-metamask-injected-web3js do the trick?

One more question, is ether.js stable and well supported?

1 Answer 1

4

Actually the answer can be found in the ethers.js doc.

Ethers.js supports web3 providers, so to get it to work metamask on browser is quite simple.

if (typeof web3 !== 'undefined') {
  var web3Provider = new ethers.providers.Web3Provider(web3.currentProvider, ethers.providers.networks.ropsten);
  web3Provider.getBalance("..some address.."). then(function(balance) {
    var etherString = ethers.utils.formatEther(balance);
    console.log("Balance: " + etherString);
  });
}

Your Answer

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

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