Overview
The GenLayer Points API uses Sign-In With Ethereum (SIWE) for authentication. This allows users to authenticate using their Ethereum wallet (MetaMask, WalletConnect, etc.) without passwords.Authentication endpoints use
/api/auth/ prefix (not /api/v1/).Authentication Flow
Step 1: Get Nonce
Request a nonce to include in the SIWE message.Response
Random 32-character string valid for 5 minutes
Step 2: Create SIWE Message
Construct a SIWE message following the EIP-4361 standard:The address on line 2 must be in lowercase.
Step 3: Sign Message
Use the user’s wallet to sign the message:Step 4: Login with Signature
Send the signed message to the login endpoint.Request Body
The SIWE message that was signed
The signature from the wallet (0x-prefixed hex string)
Optional 8-character referral code for new users
Response
Whether authentication was successful
The Ethereum address that was authenticated
The user’s ID in the system
Whether this is a newly created user
Session identifier (for debugging)
User’s unique referral code
Information about who referred this user (if any)
Verify Authentication Status
Check if the current session is authenticated.cURL
Response
Logout
Clear the authentication session.cURL
Response
Refresh Session
Extend the session lifetime to prevent expiration.cURL
Response
Session Management
Session Cookies
Authentication uses HTTP-only session cookies:- Cookie name:
sessionid - Secure flag:
true(HTTPS only in production) - SameSite:
Lax - Lifetime: Configurable (default 2 weeks)
Making Authenticated Requests
Error Responses
Invalid Signature
Expired Nonce
Missing Required Fields
Invalid Message Format
Security Considerations
Nonce Security
Nonce Security
- Nonces are valid for 5 minutes
- Each nonce can only be used once
- Nonces are automatically cleaned up after use
Address Validation
Address Validation
- Signatures are verified using eth_account library
- Address in message must match recovered address from signature
- Addresses are stored in lowercase for consistency
Session Security
Session Security
- Sessions use HTTP-only cookies (not accessible to JavaScript)
- Secure flag enabled in production (HTTPS only)
- Session expiration is enforced
Referral Code Security
Referral Code Security
- Referral codes are validated during signup
- Self-referral is prevented
- Invalid codes don’t cause signup to fail
Best Practices
- Always check authentication status before making requests
- Handle wallet connection errors gracefully
- Store session cookies securely (HTTP-only)
- Implement session refresh for long-lived applications
- Clear sessions on logout to prevent unauthorized access
Next Steps
User Endpoints
Access user profile and data
Contributions
Submit and manage contributions