Skip to main content

Request Solana challenge

POSThttps://authapi.moralis.io/challenge/request/solana
BODY PARAM
domainstringrequired
RFC 4501 dns authority that is requesting the signing.
networkstringrequired
The network where Contract Accounts must be resolved.
addressstringrequired
Solana public key with a length of 32 - 44 characters that is used to perform the signing
statementstring

Human-readable ASCII assertion that the user will sign, and it must not contain .

uristringrequired
RFC 3986 URI referring to the resource that is the subject of the signing (as in the subject of a claim).
expirationTimestring
ISO 8601 datetime string that, if present, indicates when the signed authentication message is no longer valid.
notBeforestring
ISO 8601 datetime string that, if present, indicates when the signed authentication message will become valid.
resourcesarray
List of information or references to information the user wishes to have resolved as part of authentication by the relying party. They are expressed as RFC 3986 URIs separated by new lines.
timeoutnumberrequired
Time in seconds before the challenge is expired
Responses
API KEY
import Moralis from 'moralis';

try {
await Moralis.start({
apiKey: 'YOUR_API_KEY',
});

// Values set in the backend
const DOMAIN = 'defi.finance';
const STATEMENT = 'Please sign this message to confirm your identity.';
const URI = 'https://defi.finance';
const EXPIRATION_TIME = '2023-01-01T00:00:00.000Z';
const TIMEOUT = 15;

// Values provided by the user
const address = '26qv4GCcx98RihuK3c4T6ozB3J7L6VwCuFVc7Ta2A3Uo';
const solNetwork = 'mainnet';
const network = 'solana';

const result = await Moralis.Auth.requestMessage({
address,
solNetwork,
network,
domain: DOMAIN,
statement: STATEMENT,
uri: URI,
expirationTime: EXPIRATION_TIME,
timeout: TIMEOUT,
});
} catch (e) {
console.error(e);
}
Response Example
{
"id": "fRyt67D3eRss3RrX",
"message": "defi.finance wants you to sign in with your Solana account:\n26qv4GCcx98RihuK3c4T6ozB3J7L6VwCuFVc7Ta2A3Uo\n\nI am a third party API\n\nURI: http://defi.finance\nVersion: 1\nNetwork: mainnet\nNonce: PYxxb9msdjVXsMQ9x\nIssued At: 2022-08-25T11:02:34.097Z\nExpiration Time: 2022-08-25T11:12:38.243Z\nResources:\n- https://docs.moralis.io/",
"profileId": "0xbfbcfab169c67072ff418133124480fea02175f1402aaa497daa4fd09026b0e1"
}