How to update web3auth to version 7 from 3

Hi,

I got error when login with web3auth and they said need update to version 7. How to update, change package.json ? Or update Moralis version ?

As per our old docs it looks like we were import the web3auth sdk through script tag or npm module. So if their existing functions are still valid with the new version then update the web3auth package version should be enough.
https://v1docs.moralis.io/moralis-dapp/users/web3-login/web3auth

In case if it still does not work you will mostly need to migrate to use web3auth directly.

thank bro for your info

Hi @johnversus,

How to use web3auth directly with Moralis ? can you share doc or code sample ?
My current code use Moralis with web3auth as plugin login

const {
    authenticate,
    enableWeb3,
    isAuthenticated
  } = useMoralis();
await enableWeb3({
        throwOnError: true,
        provider: 'web3Auth',
        clientId: process.env.NEXT_PUBLIC_API_KEY_WEB3AUTH,
        chainId: process.env.NEXT_PUBLIC_MAIN_NET_CHAINID,
        appLogo: process.env.NEXT_PUBLIC_URL + '/logo.png',
        rpcTarget: process.env.NEXT_PUBLIC_RPC_TARGET,
   const {account, chainId} = Moralis;

      if (!account) {
        throw new Error('Connecting to chain failed, as no connected account was found');
      }
      if (!chainId) {
        throw new Error('Connecting to chain failed, as no connected chain was found');
      }
      const {message} = await Moralis.Cloud.run('requestMessage', {
        address: account,
        chain: parseInt(chainId, 16),
        network: 'evm',
      });

      setLoading(true);
      const re = await authenticate({
        provider: 'web3Auth',
        clientId: process.env.NEXT_PUBLIC_API_KEY_WEB3AUTH,
        chainId: process.env.NEXT_PUBLIC_MAIN_NET_CHAINID,
        appLogo: process.env.NEXT_PUBLIC_URL + '/logo.png',
        rpcTarget: process.env.NEXT_PUBLIC_RPC_TARGET,
        uxMode: 'popup',
        whiteLabel: {
          name: '',
          logoLight: process.env.NEXT_PUBLIC_URL + '/logo.png',
          logoDark: process.env.NEXT_PUBLIC_URL + '/logo.png',
          defaultLanguage: 'en',
          dark: true, // whether to enable dark mode. defaultValue: false
          theme: '#D72F7A',
        },
        signingMessage: message,
        throwOnError: true,
      });

Are you using selfhost or Moralis server?

I using self-host. using Moralis v2

In theory, it should be possible to integrate custom web3 authentication with the parse server. We only have a few basic tutorials for it.

Have a look at this tutorial showing how to integrate Moralis Auth API with the parser server. In this, we show how you setup the backend with Auth API in the parse server and using the parse client to login using metamask wallet.

This tutorial does not use the Moralis v1 client sdk so it requires some prior knowledge on how to use parse server client sdk’s.

The same client-side logic can be used with web3auth as well.

Hi @johnversus,

I setup authen via Moralis with provider Web3auth by link https://v1docs.moralis.io/moralis-dapp/users/web3-login/web3auth .
As you know, just only install 1 package

Everything is OK till 3 days ago Web3auth could not redirect with error:

I ask Web3auth support and they said need update to V4 or V5 (now im saw V3). I update latest @web3auth/web3auth but same error. Can you help me check this bug or what can I do for fix this bug ?
If can use web3auth directly with Moralis, How to can I do that?
Plsssss

My issues same : Web3Auth OpenLogin Redirect problem

v1 sdk might not get an update as it is not in development. So using this alternate way will be a better option.

Im using moralis v2 , how to upgrade for fix thΓ­ bugs?

Can you share another way for this? How to can i login with moralis authen via web3auth on v2 moralis?

Here is another tutorial for login with web3auth using auth API. It uses next js 12 framework for frontend and uses its backend API routes for auth API functions.

1 Like

thank bro, i will try

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