/challenge/verify/evm request body

The message is generated first, you can generate it directly in swagger, sign it and then verify it.

The generated message seemed to be multiline which is returned from the request message.

I’m putting this message

deblog.club wants you to sign in with your Ethereum account:\n0x41Dd2e751dF10b27356cd1790567Ba6C4B5d933b\n\nPlease sign this message to confirm your identity.\n\nURI: http://localhost:3000\nVersion: 1\nChain ID: 1\nNonce: waXwRE8zYj9WBEfVx\nIssued At: 2022-09-27T14:02:19.212Z

Instead of this one. Cause it should be one line.

deblog.club wants you to sign in with your Ethereum account:
0x41Dd2e751dF10b27356cd1790567Ba6C4B5d933b

Please sign this message to confirm your identity.

URI: http://localhost:3000
Version: 1
Chain ID: 1
Nonce: waXwRE8zYj9WBEfVx
Issued At: 2022-09-27T14:02:19.212Z

Right?

Yes, it should be one line

1 Like

Ok. So the curl request it like this

curl --request POST \
     --url https://authapi.moralis.io/challenge/verify/evm \
     --header 'X-API-KEY: GDlFIJ8uIErqaQCfxxxxxxxxxxxxxxxxxxxxxxxxW36wjmwWb' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
     "signature": "0xbc53bf24906e51d0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf285171b",
     "message": "deblog.club wants you to sign in with your Ethereum account:\\n0x41Dd2e751dF10b27356cd1790567Ba6C4B5d933b\\n\\nPlease sign this message to confirm your identity.\\n\\nURI: http://localhost:3000\\nVersion: 1\\nChain ID: 1\\nNonce: tL8ejuiK6RUFhPXrE\\nIssued At: 2022-09-27T16:55:03.381Z"
}

and it returns 400. Why?

response

{
  "statusCode": 400,
  "name": "Error",
  "message": "Invalid message: {\"success\":false,\"state\":103,\"length\":276,\"matched\":0,\"maxMatched\":60,\"maxTreeDepth\":15,\"nodeHits\":258,\"inputLength\":276,\"subBegin\":0,\"subEnd\":276,\"subLength\":276}"
}

I regenerate the signature more than 10 times and try it. But the response is 400 every time. I think I input something wrong. Because the error message clearly says “Invalid message”

this format seems strange, maybe it is expected to be with two \

hmm. I changed like this. but it’s not working.

deblog.club wants you to sign in with your Ethereum account:\\0x41Dd2e751dF10b27356cd1790567Ba6C4B5d933b\\\\Please sign this message to confirm your identity.\\\\URI: http://localhost:3000\\Version: 1\\Chain ID: 1\\Nonce: tL8ejuiK6RUFhPXrE\\Issued At: 2022-09-27T16:55:03.381Z

This one is not working as well.

curl --request POST \
     --url https://authapi.moralis.io/challenge/verify/evm \
     --header 'X-API-KEY: GDlFIJ8uIErqaQCfTQxxxxxxxxxxxxxxxwjmwWb' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
     "signature": "0x33ab7687c3bf3xxxxxxxxxxxxxxxxxxxx336188a0496c03f161b",
     "message": "deblog.club wants you to sign in with your Ethereum account: 0x41Dd2e751dF10b27356cd1790567Ba6C4B5d933b  Please sign this message to confirm your identity.  URI: http://localhost:3000 Version: 1 Chain ID: 1 Nonce: uuY77ky0uqo4dGhCD Issued At: 2022-09-27T18:56:01.089Z"
}
'

you could try with \n instead of \\n

maybe this tutorial will help you more

1 Like

oh yeah. This is nice. I’ll go though this document. Thx!

1 Like

you could try with \n instead of \\n

The error message is slightly different if I send a message with \n

{
  "statusCode": 400,
   "name": "NotFoundException",
   "message": "Challenge not found, Timeout may have exceeded"
}

Why? it’s changed??

there is a timeout for a challenge, that default time of 15 seconds that you could change to more

Even if I set the timeout to 60, the result is all the same.

Also I send the verify request instantly. It’s within a second.

const config = {
  domain: process.env.APP_DOMAIN,
  statement: 'please ...',
  uri: process.env.NEXTAUTH_URL,
  timeout: 60,
};

export default async function handler(req, res) {
  const { address, chain, network } = req.body;

  await Moralis.start({ apiKey: process.env.MORALIS_API_KEY });

  try {
    const message = await Moralis.Auth.requestMessage({
      address,
      chain,
      network,
      ...config,
    });

ok, then not the timeout is the issue, how does the message looks like now?

Now it’s like this

{
  "statusCode": 400,
   "name": "NotFoundException",
   "message": "Challenge not found, Timeout may have exceeded"
}

I mean the request that you send, what is the message there that was signed.

message is like this

"deblog.club wants you to sign in with your Ethereum account:\n0x41Dd2e751dF10b27356cd1790567Ba6C4B5d933b\n\n\nURI: http://localhost:3000\nVersion: 1\nChain ID: 1\nNonce: ub6VkbzlwN
q3ueHBM\nIssued At: 2022-09-28T08:42:01.303Z"

You may need to add more fields to that message, like not before

It’s because just I change the statement to blank when I Moralis.Auth.requestMessage.

const config = {
  domain: process.env.APP_DOMAIN,
  statement: '',
  uri: process.env.NEXTAUTH_URL,
  timeout: 60,
};

So the message is changed only statement part.