---
eip: 4361
label: ERC-4361
title: Sign-In with Ethereum
status: Final
type: Standards Track
category: ERC
created: 2021-10-11
requires: 55, 137, 155, 191, 1271, 1328
official: https://eips.ethereum.org/EIPS/eip-4361
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-4361.md
canonical: https://eips.huatuo.xyz/eip-4361/
lang: en
tldr: "Sign-In with Ethereum (SIWE): a standard plain-text message that a wallet signs to log in to a website, giving apps a self-custodial alternative to 'Sign in with Google'."
tags: [authentication, wallet, siwe, signature, identity]
---

# ERC-4361: Sign-In with Ethereum

> Off-chain authentication for Ethereum accounts to establish sessions.

**TL;DR:** Sign-In with Ethereum (SIWE): a standard plain-text message that a wallet signs to log in to a website, giving apps a self-custodial alternative to 'Sign in with Google'.

## What problem does it solve?

Many dapps already let users "log in" by signing a message with their wallet, then set a session cookie. But every site invented its own message text. Wallets could not tell a login request apart from any other signature, users saw inconsistent prompts, and many implementations forgot basics such as replay protection or checking which site actually asked for the signature, which made phishing easy.

ERC-4361 standardises the message format and the checks both sides must do, so any wallet can recognise and safely display a login request, and any server can verify it the same way.

## How it works

1. The site (relying party) builds a SIWE message, usually with a server-generated `nonce`.
2. The wallet shows it and signs it with the [ERC-191](/eip-191/) `personal_sign` format (`\x19Ethereum Signed Message:\n<len>`).
3. The server checks the message fields and the signature, then creates a session bound to the **address**.

The message is human-readable text with a strict grammar (defined in ABNF):

```text
example.com wants you to sign in with your Ethereum account:
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

I accept the ExampleOrg Terms of Service: https://example.com/tos

URI: https://example.com/login
Version: 1
Chain ID: 1
Nonce: 32891756
Issued At: 2021-09-30T16:25:24Z
```

Required fields: `domain`, `address` ([EIP-55](/eip-55/) checksummed where applicable), `URI`, `Version` (`1`), `Chain ID`, `Nonce` (at least 8 alphanumerics) and `Issued At`. Optional: `scheme`, `statement`, `Expiration Time`, `Not Before`, `Request ID` and a list of `Resources` URIs.

Key rules:

- **Wallets** MUST check that `scheme`/`domain` match the real origin of the request and must show at least the domain, address, statement and resources before signing. This is the anti-phishing core of the spec.
- **EOAs** are verified with ERC-191 `ecrecover`; **contract wallets** SHOULD be verified with [ERC-1271](/eip-1271/) `isValidSignature` on the chain given by `Chain ID`.
- Servers must verify the nonce, timing fields and domain, and bind the session to the address, not to things that can change such as an ENS name.

## Sample code

Client side with ethers v6, building the message by hand:

```ts
import { BrowserProvider } from "ethers";

const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const address = await signer.getAddress();
const { chainId } = await provider.getNetwork();
const nonce = await fetch("/api/nonce").then((r) => r.text()); // server-generated

const message = [
  `${window.location.host} wants you to sign in with your Ethereum account:`,
  address,
  "",
  "Sign in to Example.",
  "",
  `URI: ${window.location.origin}`,
  "Version: 1",
  `Chain ID: ${chainId}`,
  `Nonce: ${nonce}`,
  `Issued At: ${new Date().toISOString()}`,
].join("\n");

const signature = await signer.signMessage(message); // ERC-191 personal_sign
await fetch("/api/verify", { method: "POST", body: JSON.stringify({ message, signature }) });
```

On the server, parse the message, check domain/nonce/expiry, then compare `ethers.verifyMessage(message, signature)` with the address (or call ERC-1271 for contract wallets).

## Things to know

- Status: **Final**. Libraries exist (e.g. the `siwe` npm package) that implement parsing and verification; prefer them over hand-rolled parsers.
- Authentication only: authorisation and interpretation of `Resources` are out of scope. [ERC-5573](/eip-5573/) (ReCaps) builds capability delegation on top.
- Use a fresh, high-entropy nonce per sign-in and reject reused ones, or a captured signature can be replayed.
- ERC-1271 results depend on chain state, so sessions for contract wallets may need invalidating when signers change.
- ERC-191 was chosen over EIP-712 because wallets display plain text more readably; the message is not designed for on-chain verification.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-4361
