1

I am developing a Dapp that is going to use Metamask for user interactions.

I have two related questions:

It seems the Metamask extension already comes with a ethereum provider that it injects into the browser. Am I right on this point?

If that is the case, do I really need a separate ethereum provider such as ethers.js (https://docs.ethers.io/)?

2

Metamask provides the ethereum object in your browser JS API to interact with the wallet. With that you can send transactions and interact with the chain. See https://docs.metamask.io/guide/

https://docs.metamask.io/guide/getting-started.html#basic-considerations

Once MetaMask is installed and running, 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 in over the course of 2020, we are introducing significant changes to this API, and we recommend that you refer to its documentation.

But at some point, you will have to call contract methods and build data using the ABI and that's where libraries will help: https://docs.metamask.io/guide/initializing-dapps.html#the-contract-abi

The Contract ABI In Ethereum, The ABI Specification (opens new window)is a way to encode the interface of a smart contract in a way that your user interface can make sense of. It is an array of method-describing objects, and when you feed this and the address into a contract-abstraction library, this ABI tells those libraries about what methods to provide, and how to compose transactions to call those methods.

Example libraries include:

ethers(opens new window) web3.js(opens new window) Embark(opens new window) ethjs(opens new window) truffle

Otherwise you will have to build the data by yourself to provide it to the Metamask Ethereum object. Not very convenient.

So Metamask object is enough, but having a library is better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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