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