The signInWithEthereum capability enables secure user authentication following the SIWE (Sign-In With Ethereum) standard. This capability is only available with the
wallet_connect method and provides a standardized way to authenticate users with their Ethereum accounts.Parameters
A unique random string to prevent replay attacks. Should be generated fresh for each authentication attempt.
The chain ID as a hexadecimal string (e.g., “0x2105” for Base Mainnet).
Returns
Authentication result containing the signed message and signature.
Usage with wallet_connect
ThesignInWithEthereum capability must be used with the wallet_connect method:
Security Considerations
Nonce Management
Always use fresh, unique nonces for each authentication attempt:Backend Verification
Verify signatures on your backend to prevent tampering:Integration Examples
Express.js Backend
React Integration
Error Handling
Base Account signatures include ERC-6492 wrapper for undeployed smart wallets, which viem’s
verifyMessage handles automatically.Best Practices
- Fresh Nonces: Always generate unique nonces for each authentication attempt
- Secure Generation: Use cryptographically secure random number generation
- Nonce Tracking: Track used nonces on your backend to prevent replay attacks
- Signature Verification: Always verify signatures on your backend, never trust client-side verification
- Session Management: Create secure sessions or JWT tokens after successful verification