How can I use Moralis to get the public address of a website visitor once they authorize it through their metamask wallet?

At the moment on pc, my users have the option to click on a ā€œlogin to metamaskā€ button, and if they have the metamask chrome extension installed I simply have to access the window.ethereum object and Iā€™ll get their public address.

This solution is great but it doesnā€™t work if the user is browsing from mobile. I want to use moralis to do so but I couldnā€™t find a way. I see databases, react components, all noise around but I canā€™t find the one solution that would simply let an user link their metamask to my website and give me back their public address.

Is there any easy way to do so with Moralis?

You can get that address from current user object, address that is stored in db in user row

Is there a page you could link? Idonā€™t know where to startā€¦All I want is for the user to press a button, runsome Moralis to get them to link their metamask wallet to my website and get back their public address. No react and possibly no writing to databases involved.

You get the user from a syntax similar to Moralis.User.current() and then you look on what attribute has that user object

1 Like