Walletconnect v2 Moralis integration

Hello,

I am trying to integrate Walletconnect v2 into my dapp. I did all the steps here (https://github.com/WalletConnect/web3modal/blob/V2/examples/nextjs-standalone/src/pages/index.tsx ). The application seems to be connected to the walletconnect, but after connecting, no moralis user is created and Moralis.User.current() returns null. How can I do Moralis.authenticate after walletconnect connection. When you do it as follows, it opens the old walletconnect qr.

authUser = await authenticate({ signingMessage: message, provider: 'walletconnect', throwOnError: true });

Hello,

what happens, did you end up signing a message? it makes a request to the server will the signature and the message and after that it doesn’t work?

  async function onOpenModal() {
        if (signClient) {
          const namespaces = {
            eip155: {
             methods: [
                "eth_sendTransaction",
                "eth_signTransaction",
                "eth_sign",
                "personal_sign",
                "eth_signTypedData"], chains: ['eip155:1'], events: ['accountsChanged'] }
          }
          const { uri, approval } = await signClient.connect({ requiredNamespaces: namespaces })
          if (uri) {
            await web3Modal.openModal({ uri, standaloneChains: namespaces.eip155.chains })
            let session = await approval();
            console.log("session",session)
            const result = await signClient.request({
                topic: session.topic,
                chainId: "eip155:1",
                request: {
                  id: 1,
                  jsonrpc: "2.0",
                  method: "personal_sign",
                  params: [
                    "0x1d85568eEAbad713fBB5293B45ea066e552A90De",
                    "0x7468697320697320612074657374206d65737361676520746f206265207369676e6564",
                  ],
                },
              });
            connectWalletPressed(result);
            web3Modal.closeModal()
          }
        }
      }
connectWalletPressed(message) {
            let authUser;
            let chains = ['0x89']
            const provider = await EthereumProvider.init({
                projectId: <projectId>, 
                chains: chains
            });
            console.log("provider",provider)
            try {
                /*await enableWeb3({ throwOnError: true, provider:'walletconnect' });

                const { message } = await Moralis.Cloud.run('requestMessage', {
                    address: '0x9ddd48bEdD68FEf6FF82c70D2b9b1Fa531bc7758',
                    chain: '0x89',
                    network: 'evm',
                });*/
                               
                authUser = await authenticate({ signingMessage: message, provider: 'walletconnect', throwOnError: true })
               
           
            } catch (error) {
                await deactivateWeb3();
                await logout();
                console.log("error", error);
                toast.error('Wallet Authentication Failed', toastOptions);
                return;
            }```

what happens? do you get to sign the message?

I comment line the part where I sent a sign message to my self hosted server, because in the walletconnect v2 document, the sign operation is done as in the openmodal function and the sign message is sent to the wallet. If the user signs the message, I want to authenticate the moralis user, but when I do it this way, the old walletconnect qr opens again.

I’m just wondering, my user is connecting to my dapp with walletconnect v2 by scanning the qr. The connection seems to be successful, but I don’t know how to do moralis authentication. After the user makes the walletconnect connection, I want to authenticate on the moralis side.

moralis authentication has 2 steps, first step is to sign that message and the second step is to send the signed message and the signature to the server in order to authenticate

the important part is with signing the message

Until now, I was already connecting to walletconnect v1 without any problems. Can you tell me how to authenticate the user on moralis side in walletconnect v2? My question has nothing to do with your answers. my wallet is connected but why is Moralis.User.current() is null.
When I run the auth function in your document below, walletconnect v1 opens its qr.


When I run the auth function below that you gave when you rushed to the self-hosted, it opens the walletconnect v1 qr for me.

Can you tell me how can I create Moralis.User after i connected with walletconnect v2?

that user info is from the database, I don’t know what you expect here or when you call it

I don’t know now what are the required changes to use wallet connect v2 with a self hosted parse server

https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e
you still have time until June to migrate to wallet connect v2

I know thank you. Will moralis update the authentication functions for wallet connect v2? When will the new guide come?

For all the V1 SDK, unfortunately no, since we have deprecated the package a while ago. We are not going to add anymore updates or maintain the V1 SDKs in the future. So you might need to implement it yourself.

You might want to take a look into this https://v1docs.moralis.io/moralis-dapp/users/web3-login/custom-auth-any-eip1193-provider

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