Try it Live
Run SIWE examples in the interactive playground
Conceptual Guide - For API reference and method documentation, see SIWE API.
What is SIWE?
SIWE (EIP-4361) standardizes Ethereum-based authentication. Instead of usernames and passwords, users sign a message with their wallet to prove they control an address.Why SIWE Exists
Traditional web authentication relies on centralized identity providers (Google, Twitter, etc.). SIWE enables:- Self-sovereign identity - Users own their credentials (private keys)
- No intermediaries - Direct cryptographic proof, no OAuth handshakes
- Privacy - No personal data required, just address ownership
- Standardization - Common format for Ethereum authentication across dApps
Message Format
SIWE messages are human-readable structured text. Users read and sign them with wallets:Message Components
Each field serves a specific security or usability purpose:- Domain - Origin where signing occurs (prevents phishing)
- Address - Account performing authentication
- Statement - Human-readable context (optional)
- URI - Resource being accessed
- Version - Protocol version (always “1”)
- Chain ID - Which blockchain (prevents replay across chains)
- Nonce - One-time random value (prevents replay attacks)
- Issued At - Timestamp when message created
- Expiration Time - When message becomes invalid (optional)
- Not Before - When message becomes valid (optional)
- Request ID - System identifier (optional)
- Resources - List of granted URIs (optional)
Authentication Flow
SIWE follows a multi-step process:Why Nonces Matter
Without nonces, attackers could replay old signed messages to impersonate users. Nonces ensure each signature is single-use:Complete Example: Authentication
Full authentication flow from message creation to verification:- Frontend
- Backend
Signing and Verification
SIWE uses EIP-191 personal sign standard:Combined Validation and Verification
UseverifyMessage() for complete validation:
Security Considerations
Domain Binding
Always verify the domain matches your origin to prevent phishing:attacker.com on example.com because the domain is in the signed message.
Nonce Management
Implement proper nonce handling:Expiration Times
Set reasonable expiration windows:HTTPS in Production
Always use HTTPS in production to prevent man-in-the-middle attacks. SIWE doesn’t encrypt messages - they’re signed plaintext.Common Use Cases
dApp Login
Authenticate users to access dApp features:Session Management
Create time-limited sessions:Resource Authorization
Grant access to specific resources:Resources
- EIP-4361: Sign-In with Ethereum - Full specification
- EIP-191: Signed Data Standard - Message signing format
- siwe.xyz - Official SIWE website with tools and libraries
- login.xyz - Reference implementation and examples
Next Steps
- Overview - Type definition and API reference
- Constructors - Create SIWE messages
- Signing - Sign and hash messages
- Verification - Verify signatures
- Validation - Validate message structure
- Usage Patterns - Real-world authentication flows

