Skip to main content
Defined in EIP-4361
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

nonce
string
required
A unique random string to prevent replay attacks. Should be generated fresh for each authentication attempt.
chainId
string
required
The chain ID as a hexadecimal string (e.g., “0x2105” for Base Mainnet).

Returns

signInWithEthereum
object
Authentication result containing the signed message and signature.

Usage with wallet_connect

The signInWithEthereum 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

The signInWithEthereum capability only works with the wallet_connect method. Using it with other methods like eth_requestAccounts will not work.
Base Account signatures include ERC-6492 wrapper for undeployed smart wallets, which viem’s verifyMessage handles automatically.

Best Practices

  1. Fresh Nonces: Always generate unique nonces for each authentication attempt
  2. Secure Generation: Use cryptographically secure random number generation
  3. Nonce Tracking: Track used nonces on your backend to prevent replay attacks
  4. Signature Verification: Always verify signatures on your backend, never trust client-side verification
  5. Session Management: Create secure sessions or JWT tokens after successful verification