I am hoping to migrate to using Ethers.js since it is much more lite weight than Web3.js. However, it appears that Moralis uses Web3. Has the team considered providing another option?
You are free to use any web3 provider that you want. We use web3 internally, but you can use ethers.js if you want.
Instead of using
const web3 = await Moralis.Web3.enable(), you can setup your web3 provider via ethers.js.
Also note, this article in the ethers.js docs might help you out: https://docs.ethers.io/v5/migration/web3/
Wow that is great to hear. Just to make sure I understand correctly, so that means the Moralis front-end plugin/library does not come pre-attached with Web3.js, and the web3.js library is only downloaded by the client-side browser if and when const web3 = await Moralis.Web3.enable() is called, right?
Ah, I see what you mean now. If you’re interested in the bundle size, than this won’t work.
Web3 is included in the sdk, as it is used in functions in the sdk. But you still can use ethers.js additionally if you prefer. It will increase the bundle size though, as you include both libraries.
I agree, it would be nice to let users provide the preferred web3 library. Great suggestion. We’ll add it to the feature requests
Oh I see. In that case I will stick with using web3.js. Yes, an option to choose the web3 library would be great. Thanks for adding the feature request
I will second that. It would be awesome to use ethers.js directly from the SDK.