Connect Wallet without always having to sign message

Hello all,

Is their anyway we can utilize the fact that once we connect a meta mask wallet, meta mask saves the site in its “connected sites” therefore not having to have the user always needing to sign a message to get access to the dapp.

Almost all dapps/defi sites etc that I go too after the first time I connect my meta mask to it, it just requires to me to be on the specific network in order for the dapp to work.

Thank you

Well I did figure it out, but when I sign in via web3 if I refresh my page it resets and I have to click connect wallet again

can you give more details, are you using authenticate or enableWeb3 to connect? both should be persistent and you shouldn’t need to reconnecting to metamask

I am using enableWeb3(), i have a simple check to see if i am logged in via web 3. When I refresh my page the ui shows my connect wallet button again.

const {

    Moralis,

    onChainChanged,

    isWeb3Enabled,

    enableWeb3,

    logout,

    account,

    chainId,

  } = useMoralis();

{isWeb3Enabled ? (

              <>

                <Button className='ms-2' variant='success'>

                  {formatUserAddress(account)}

                </Button>

                <Button

                  className='ms-2'

                  variant='danger'

                  onClick={() => logout()}

                >

                  Disconnect

                </Button>

                <Button

                  className='ms-2'

                  variant='danger'

                  onClick={() => logout()}

                >

                  {chainId}

                </Button>

              </>

            ) : (

              <Button variant='success' onClick={() => enableWeb3()}>

                Connect Wallet

              </Button>

            )}

coz when you use enableWeb3 it is simply connecting to metamask but not authenticated (with Moralis server session), which if you want it not to render the connect wallet button, then you need to check whether account is null or not :raised_hands:

2 Likes