Skip to main content
Change page

Authentication on Ethereum

If you're coming from traditional web development, you're used to username/password login, OAuth flows, and session cookies. Authentication on Ethereum works differently—and in many ways, more simply.

On Ethereum, a user proves their identity by signing a message with their wallet. No password to store. No database of credentials to leak. Just cryptography.

How is it different from web2?

Web2Ethereum
Username + passwordWallet address + signature
Server stores credentialsUser holds private key
Sessions managed by cookies / JWTSessions begin with an offchain wallet signature
"Sign in with Google""Sign in with Ethereum"
Password reset flowsSeed phrase recovery

The fundamental shift: in web2, a centralized server authenticates you. On Ethereum, you authenticate yourself by proving you control a specific address—and anyone can verify it independently.

Prerequisites

Make sure you understand:

How wallet-based authentication works

The core flow is simple:

  1. Your dapp asks the user to connect their wallet (via MetaMask, Rainbow, WalletConnect, etc.)
  2. The wallet shares the user's Ethereum address - this is their public identifier
  3. Your dapp generates a unique message (a nonce or challenge)
  4. The user signs the message with their private key (happens inside the wallet)
  5. Your backend verifies the signature against the claimed address
  6. If valid, the user is authenticated

No password was ever typed, stored, or transmitted.

Sign-In with Ethereum (EIP-4361)

EIP-4361 (opens in a new tab) defines a standard message format for Ethereum sign-in, commonly called SIWE (Sign-In with Ethereum). It replaces ad-hoc message signing with a structured, secure standard.

A SIWE message looks like this:

Key features of SIWE:

  • Domain binding - the message includes the domain, preventing phishing
  • Chain ID - specifies which network the signature is valid for
  • Nonce - prevents replay attacks
  • Expiration - optional timestamp limiting validity window
  • Resources - optional URIs for scoped access

SIWE libraries

Example: client-side sign-in with siwe

Example: server-side verification (Node.js)

Wallet connection libraries

Before authenticating, you need the user to connect their wallet. These libraries make it easy:

Verifying signatures manually

If you prefer not to use SIWE, you can verify signatures directly:

Important security notes

  • Always use a nonce - prevents replay attacks where an old signature is reused
  • Include the domain - prevents signatures from being valid across different sites
  • Check expiration - signatures should have a limited validity window
  • Use SIWE (EIP-4361) when possible - it handles all of the above for you
  • Never expose private keys - the signature happens inside the wallet; your app only sees the result

Session management

Once authenticated, you still need sessions—just like web2. Common patterns:

  • JWT tokens - issue a JWT after verifying the signature, use for API requests
  • Server-side sessions - store the verified address in a session cookie
  • SIWE with resources - define scoped access tokens linked to specific URIs

The key difference from web2: the user's Ethereum address is their persistent identity. They can use it across any dapp without creating a new account.

Decentralized identity

Ethereum authentication is part of a broader movement toward self-sovereign identity. Standards and projects in this space include:

Further reading