Skill — Copyable reference implementation. Use as-is or customize. See Skills Philosophy.
Overview
SIWE authentication flow:- Server generates a unique nonce
- Client creates a SIWE message with the nonce
- User signs the message with their wallet
- Server verifies the signature matches the address in the message
- Server creates a session for the authenticated user
Creating SIWE Messages
UseSiwe.create() to construct a message with required fields:
Adding Optional Fields
Include statement, expiration, and resources for enhanced messages:Custom Nonce
For server-generated nonces, pass your own value:Formatting Messages for Signing
Convert the message object to the EIP-4361 text format for wallet signing:Signing SIWE Messages
The message hash uses EIP-191 personal sign format. Sign with any Ethereum wallet:Using PrivateKeySigner (Server-side or Testing)
Using Browser Wallet (Client-side)
Verifying SIWE Signatures
Basic Verification
Siwe.verify() checks that the signature was created by the address in the message:
Full Message Verification
Siwe.verifyMessage() validates both the signature and message constraints (expiration, notBefore):

