Back
+20 XP
4/12
Challenge: Build a SIWS Message
Construct a properly formatted Sign-In With Solana (SIWS) message that can be used for authentication.
Requirements
- Create a function that accepts
domain(string),publicKey(PublicKey),nonce(string), andstatement(string) - Generate an ISO timestamp for "Issued At" (use
new Date().toISOString()) - Return a formatted SIWS message string following this structure:
{domain} wants you to sign in with your Solana account: {publicKey} {statement} URI: https://{domain} Version: 1 Nonce: {nonce} Issued At: {issuedAt}
Test Cases
Returns a SIWS message string containing the domain
Input:
'academy.courses', sender, 'nonce123', 'Sign in'Expected: typeof result === 'string' && result.includes('academy.courses')Includes the version header and reflects the nonce
Input:
'academy.courses', sender, 'nonce123', 'Sign in'Expected: result.includes('Version: 1') && result.includes('Nonce: nonce123')Includes the URI (built from the domain) and an Issued At timestamp
Input:
'academy.courses', sender, 'nonce123', 'Sign in'Expected: result.includes('URI: https://academy.courses') && result.includes('Issued At:')