[SOLVED] Moralis Auth API only allows 44 character Solana wallets

Problem: The moralis auth api /challenge/request/solana endpoint only allows 44 character Sol addresses, but valid Sol addresses range from 32 to 44 characters.

Questions:

  1. Is there a reason for this (and if not can a fix be made)?
  2. Is there a way I can lift this validation manually in the SDK? I’m assuming not since it seems like the validation happens in the api.

API Error Message:

{
  "statusCode": 400,
  "name": "BadRequestException",
  "message": [
    "address must be longer than or equal to 44 characters"
  ]
}

Javascript SDK Error Message:

error - TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'TLSSocket'
    --- property '_httpMessage' closes the circle
    at JSON.stringify (<anonymous>)
    at sendJson (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/api-utils/node.js:197:19)
    at apiRes.json (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/api-utils/node.js:350:31)
    at __WEBPACK_DEFAULT_EXPORT__ (webpack-internal:///(api)/./pages/api/auth/request-message.ts:36:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.apiResolver (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/api-utils/node.js:366:9)
    at async DevServer.runApi (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/next-server.js:481:9)
    at async Object.fn (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/next-server.js:735:37)
    at async Router.execute (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/router.js:247:36)
    at async DevServer.run (/Users/tylerspagnolo/test-auth/node_modules/next/dist/server/base-server.js:347:29) {
  page: '/api/auth/request-message'
}

Can you give an example of an address that is less than 44 characters?

You can do your own validation if you want instead of calling the api for validation. You just replace the last step with your own implementation.

Here’s an example of a 43 character address: wr21JKA7DeFwyrA8NCeWAF3vR2CCvw2PeziBYFfVk7u

Can you give a little more info on how I’d work around the validation using the auth api? I’m currently using the Moralis.Auth.requestMessage() function to get the message, and that’s where the validation issues start happening.

We’ll have to check, I thought that you are having issues on the second step.

It should be fixed soon. You can try again in 10-20 minutes.

2 Likes

Yep, it’s working now. Thanks for solving!

1 Like