Try it Live
Run SIWE examples in the interactive playground
Constructors
Methods for creating SIWE message instances.create
Create new SIWE message with automatic defaults.Signature
Parameters
Required:domain- RFC 4501 dns authority requesting signingaddress- AddressType performing signing (20 bytes)uri- RFC 3986 URI referring to subject of signingchainId- EIP-155 Chain ID (positive integer)
statement- Human-readable ASCII assertionexpirationTime- ISO 8601 datetime for expirationnotBefore- ISO 8601 datetime for not-beforerequestId- System-specific identifierresources- Array of resource URIsnonce- Custom nonce (auto-generated if omitted, min 8 chars)issuedAt- Custom issued time (current time if omitted)
Returns
BrandedMessage with:
versionautomatically set to"1"nonceauto-generated if not provided (11 chars, base62)issuedAtauto-set to current ISO 8601 time if not provided- Optional fields only included if provided
Example
Type Safety
Generic parameters preserve exact types:Notes
- Nonce generation: Uses
crypto.getRandomValues()for secure randomness - Timestamp format: ISO 8601 format required for all timestamps
- Version: Always “1” per EIP-4361 current specification
- Optional fields: Only present in returned object if provided (no undefined)
- Address format: Must be valid 20-byte AddressType
Common Use Cases
Session with Expiration
Resource-Restricted Access
Delayed Activation
Request Tracking
Implementation Details
- Uses conditional spreading for optional fields (no
undefinedvalues) - Delegates nonce generation to
generateNonce() - Current timestamp from
new Date().toISOString() - Version hardcoded to “1” per EIP-4361 spec
- Returns plain object (not class instance)
See Also
- Siwe.parse - Parse from formatted string
- Siwe.generateNonce - Nonce generation
- Message Format - EIP-4361 format specification
- Validation - Message validation rules

