Try it Live
Run SIWE examples in the interactive playground
Type Definition
Sign-In with Ethereum (EIP-4361) implementation for decentralized authentication. Creates structured messages users sign with private keys, proving address ownership without key exposure.Authentication Flow
Message Structure
A SIWE message is a human-readable text format combining user intent with cryptographic proof:- Domain (RFC 4501): Where the message is being signed for
- Address: Which account is signing
- URI: What resource is being accessed
- Statement: Human-readable context
- Chain ID: Which blockchain
- Nonce: One-time value, prevents replay attacks
- Timestamps: Validity window
- Resources: Optional list of what’s being granted access to
Factory
params.domain: RFC 4501 dns authorityparams.address: AddressType performing signingparams.uri: RFC 3986 URIparams.chainId: EIP-155 Chain IDparams.statement?: Human-readable assertion (optional)params.expirationTime?: ISO 8601 expiration (optional)params.notBefore?: ISO 8601 valid-from time (optional)params.requestId?: System identifier (optional)params.resources?: Resource URIs (optional)params.nonce?: Custom nonce (auto-generated if omitted)params.issuedAt?: Custom timestamp (current time if omitted)
Static Constructors
Siwe.create(params)
Siwe.parse(text)
Static Utilities
Formatting
Siwe.format(message)
Validation
Siwe.validate(message, options?)
{ valid: true } or { valid: false, error: ValidationError }
Signing & Verification
Siwe.getMessageHash(message)
Siwe.verify(message, signature)
signature: 65-byte signature (r + s + v)
Siwe.verifyMessage(message, signature, options?)
Nonce Generation
Siwe.generateNonce(length?)
length: Nonce length (default 11, min 8)
Instance Methods
All static utilities available as instance methods:Types
Implementation
- Delegates to BrandedSiwe namespace
- Extends Object.prototype
- Structured message format per EIP-4361
- Supports optional fields via conditional spreading
Quick Start
Common Patterns
Authentication Flow
Session Management
API Documentation
Constructors
Creating SIWE messages from parameters or text. View constructors →Parsing
Parse EIP-4361 formatted strings to message objects. View parsing →Validation
Validate message structure and timestamps. View validation →Signing & Verification
Create hashes and verify signatures with addresses. View signing →Utilities
Nonce generation and helper functions. View utilities →Usage Patterns
Real-world authentication and session patterns. View patterns →Quick Reference: Security Checklist
Related Types
- Address - 20-byte Ethereum addresses used in messages
- Signature - 65-byte signatures (r + s + v) for verification
- Keccak256 - 32-byte hashes from message signing

