React Moralis - How to get ethers from Moralis.web3Library

Hello,

The Moralis documents says that we can get access to the Ethers.js library that Moralis is using by doing:
const ethers = Moralis.web3Library
https://docs.moralis.io/moralis-server/web3/web3#get-the-ethersjs-library

But how can we do this in react-moralis? I have tried:
const {web3Library, web3} = useMoralis();

But web3Library is “undefined”

I’m not finding the web3 object useful as well as it’s just the Web3Provider for ethers.js and I cant work with “utilities” (like BigNumber) or “contract interaction”.

Prior to the upgrade to ethers I used to work with BN like so web3.utils.BN;

But I really would like to use ethers.

Can you please let me know how to access to the Ethers.js library from React Moralis?

Thanks!

ethers is the default :raised_hands: I believe if you use web3 from useMoralis it’ll be the ethers provider instead of web3js

also yes web3Library will be undefined as it is something from Moralis object, which you can get here

const { Moralis } = useMoralis();

Moralis.web3Library
1 Like