Error: Web3Api not initialized, run Moralis.start() first

Hello.

Is it possible to check if Moralis has started (was initialized)?

Something like this:

if(Moralis.isStarted)
{
}

Thanks.

that error looks like Moralis.start was not used

No it’s not. That’s why I am asked about checking … Because I want to use it like this:

if(!Moralis.isStarted)
{
    await Moralis.start({moralisSecret});
}

Thanks.

maybe it doesn’t matter if you use it twice in your code

1 Like

I don’t know. U tell me ) What about many-many times? That’s why I am asking about checking …

I don’t know of that flag, but you could make a separate function that calls Moralis.start and also set a flag in that function so that you know when it was set

Maybe something along these lines, not sure if this is what you mean/are looking for, just wanted to lend a hand…

const { isAuthenticated } = useMoralis();

if (!isAuthenticated) 
        await Moralis.start({moralisSecret});
        await Moralis.authenticate({});
      };

What is useMoralis(); in your case? For what I need to use await Moralis.authenticate({});?

Thanks.

useMoralis is specific to react

Hi,
I think you can use Moralis.Core?.isStarted

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.