Can't initialize user with Web3

I am trying to create user using metamask wallet and I got this error.
Here is my code.

const handleMetamaskSignup = async () => {
    await Moralis.Web3.authenticate().then((user) => {
      // eslint-disable-next-line no-console
    }).catch(err => {
      // eslint-disable-next-line no-console

And here I got this error.

trycatch.js:220          POST 400

instrument.js:109 Error: Cannot read properties of undefined (reading 'toLowerCase')
    at handleError (RESTController.js:438:1)

Could anyone can help me with this?

what version of Moralis SDK are you using?

did you try Moralis.authenticate() directly?

Thank you for your response.
This is from my package.json file.

"moralis": "0.0.184",
"react-moralis": "^0.2.8",

Can you try to get the user after doing the authentication in a separate call?

Using await in authentication and also await to get current user

You mean this way?
I tried this code but got same result.

const handleMetamaskSignup = async () => {
    const user = await metamaskSignup();

  const metamaskSignup = async () => {
    return await Moralis.Web3.authenticate();

No, I think that there is a different function to get the user that you call it after you called authenticate

Okay. Make sense.
But even if I didn’t call the function to get the user, authenticate function itself is supposed to create a new user?
I don’t see any user created in the Moralis dashboard.

it will create a new user only if that user was not already created before

Yes. I don’t any user created since I tried.
Just downloaded the boilerplate from documentation.
I will try to run that and see if that works and get back.

Thank you for your help, @cryptokid.

Anyway, creating user with metamask is not depricated or something right?

it should work without problems to create a user with metamask
you can look in your browser console to see if there is any error

Tried the boilerplate but got the same error?
Is the network of my account related to this?

what is the complete code that you have?

what is the server url?

I am trying the moralis boilerplate.
Here is the part I tried.

function Account() {
  const { authenticate, isAuthenticated, account, chainId, logout } =
  const [isModalVisible, setIsModalVisible] = useState(false);
  const [isAuthModalVisible, setIsAuthModalVisible] = useState(false);

  if (!isAuthenticated || !account) {
    return (
        <div onClick={() => setIsAuthModalVisible(true)}>
          <p style={styles.text}>Authenticate</p>
          onCancel={() => setIsAuthModalVisible(false)}
            padding: "15px",
            fontSize: "17px",
            fontWeight: "500",
          style={{ fontSize: "16px", fontWeight: "500" }}
              padding: "10px",
              display: "flex",
              justifyContent: "center",
              fontWeight: "700",
              fontSize: "20px",
            Connect Wallet
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
            {{ title, icon, connectorId }, key) => (
                onClick={async () => {
                  try {
                    await authenticate({ provider: connectorId });
                    window.localStorage.setItem("connectorId", connectorId);
                  } catch (e) {
                <img src={icon} alt={title} style={styles.icon} />
                <Text style={{ fontSize: "14px" }}>{title}</Text>

ok, this is react, I don’t know exactly how it works in react, usually you need to use useEffect in react to get the user data

1 Like

Thank you. I am gonna try with the basic sandbox and get back to you.
I really appreciate your kind help @cryptokid.

I just tried the sample code from documentation.

        <title>Metamask Demo</title>
        <script src="[email protected]/dist/web3.min.js"></script>
	<script src=""></script>
        <button onclick="login()">Login with metamask</button>
            Moralis.initialize("APP_ID"); // Application id from
            Moralis.serverURL = "SERVER_URL"; //Server url from
            async function login(){
                console.log("login clicked");
                var user = await Moralis.Web3.authenticate();

I created new server and this perfectly works fine with new test server.
But only doesn’t work when I use my main server.
I think it’s related my server config.

Have any idea what setting would affect this feature?

Maybe some rights on some tables?

Would be that one. I am checking it now. :slight_smile:

Is there any settings in the class like required field?
I see user table has write permission on so it doesn’t seem to be the cause.

Did you check all the tables?

You can also try to restart the server in case that you didn’t do that already