[SOLVED] ConnectButton web3UIkit


I’m using the ConnectButton Component from web3uikit (https://github.com/web3ui/web3uikit) in my navBar, and it works perfectly at the moment.


Now, on one of my app pages, i would like to get the address of the connected user.
The thing is, i don’t know if it’s possible and how to access the properties of the to retrieve the address of the connect user. Any ideas how to do it? Thank you in advance.

All react-moralis hooks works the same.
You can get user data from const { user } = useMoralis().
From the user from the hook, you can get the user address with user.get("ethAddress").

Thanks for the reply @qudusayo

i was using Moralis().account, but i had a error when using it with the web3API:

Here is the way i got the current user address:

Screenshot from 2022-09-12 14-39-15

The code for the API:

Screenshot from 2022-09-12 14-38-59

The error in the console, after re-loading the page.

Screenshot from 2022-09-12 14-38-42

I don’t have this issue when using user.get(“ethAddress”), do you know why ?

Better to use user.get(“ethAddress”). Using useMoralis().account will be null if isWeb3Enabled is false.

1 Like

understood, Thanks for the help.

@qudusayo At the end i used the following code:

Screenshot from 2022-09-13 11-54-17

The thing is, when switching wallets in the Metamask, userAddress always return the address of the first connected wallet. Do you know the trick to guarantee is useAddress is the address of the active wallet? Thanks in advance

When switching wallets in Metamask, you should use account in that case and make sure isWeb3Enabled is true

1 Like