Moralis.enableWeb3 vs Moralis.authenticate init Moralis DB

Hi everyone,

Iā€™m a issue : Call Moralis.enableWeb3 is not initialize the Moralis Database, but ā€œnormalā€ login, with Moralis.authenticate yes. In the documentation, i read that are equals, but it seem not.

The blue line show tables that are initialize only when i call Moralis.authenticate

Thanks in advance.

they are different. enableWeb3 only enables web3, authenticate enables web3 and also does the authentication

Thanks for the response.
Sorry but i donā€™t understand. Moralis.enableWeb3 is request metamask to authenticate the user.
And in moralis documentation, they says that Authenticate and EnableWeb3 are similar no ?

So if i want to user Moralis event to detect chain change for example, i need first authenticate, and after that enableWeb3 ? ^^

authenticate has one more step compared to enable web3, you need enableWeb3 if you want to sign a transaction for example

Ok thanks, but if i need to listen event for chain change, i donā€™t need enable3 that you sayed ? :slight_smile:

Itā€™s really not clear at all for me :confused:

For example, now iā€™m just using Moralis.authenticate, and the result is : Moralis.chainId return NULL.
I need to first authenticate, after enableweb3 manually, and after that Moralis.chainId can have the correct valueā€¦

if you use await Moralis.enableWeb3() and after that x = await Moralis.getChainId() then it should work fine

Sure that i told you :wink:

I need to clairly understand the processā€¦

First : Authenticate the user
Second : EnableWeb3
third: Init event like (OnChainChanged)
four: Get all information that i need ? (Like Moralis.getChainId)

Thanks in advance.

you can skip the authentication part if you donā€™t need it

1 Like

Yes but without authentification, i canā€™t init correctly my database and get native balance, tokens, nft etc no ?

you can use web3api calls without authentication, but it will be easier with authentication

Ok thanks for your explications & your time :wink:

Hi @cryptokid,
Iā€™m having kind of the same doubt.

We have enableWeb3 and authenticateā€¦ however both are showing the login modal (web3auth) which is not good because I have to use enableWeb3 when I load the contracts.

The authenticate returns the user logged in and the enableWeb3 doesnā€™t.

However, the user gets confused because he has to log in when the modal shows upā€¦ and then he has to log in again if I want to return the userā€¦ Iā€™m very confused.

you could make read only requests to contracts using web3api directly too (runContractFunction)

maybe you can also authenticate directly in first place