---
eip: 8019
label: ERC-8019
title: Minimal Wallet-Managed Auto-Login for SIWE
status: Review
type: Standards Track
category: ERC
created: 2025-09-02
requires: 4361
official: https://eips.ethereum.org/EIPS/eip-8019
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8019.md
canonical: https://eips.huatuo.xyz/zh/eip-8019/
lang: zh
tldr: 让钱包在本地维护一份受信任网站的白名单，当简单的匹配规则通过时，静默签署这些网站的 Sign-In with Ethereum 消息，回访用户因此可以跳过登录提示。
tags: [siwe, wallet, login, authentication, ux]
---

# ERC-8019: Minimal Wallet-Managed Auto-Login for SIWE

> Defines a wallet-local allowlist for automatic signing of ERC-4361 messages when simple match rules succeed.

**TL;DR:** 让钱包在本地维护一份受信任网站的白名单，当简单的匹配规则通过时，静默签署这些网站的 Sign-In with Ethereum 消息，回访用户因此可以跳过登录提示。

## 它解决什么问题？

[ERC-4361](/eip-4361/)（Sign-In with Ethereum，SIWE）让网站通过要求钱包签署一条结构化文本消息来认证用户。这能用，但用户最终会为同一个受信任的应用一遍又一遍地批准同一条登录消息，既繁琐，又让人养成不看内容就点"签名"的习惯。

ERC-8019 允许由**钱包**而不是应用来决定某个网站是受信任的，并使用一小组确定性的匹配规则自动签署它的 SIWE 消息。应用无需任何改动即可使用。

## 它如何运作

钱包为每个受信任的应用保存一条策略：

| 字段 | 含义 |
| --- | --- |
| `domain` | 必须与 SIWE 的 `domain` 完全相等 |
| `uriPrefix` | SIWE 的 `uri` 必须以此开头 |
| `allowedChains` | 允许的 `chainId` |
| `allowedResources` | SIWE 的 `resources` 必须是此列表的子集；如果为空，则不允许任何 resources |
| `supportsEIP6492` | 应用是否能验证智能账户签名（见下文） |
| `expiresAt` | 过期时间戳，`0` 表示不过期 |

只有当每条规则都匹配时，钱包**才可以**自动签名，并且仍必须执行所有常规的 SIWE 检查（新鲜的 nonce、时间有效性、域绑定）。

策略**只能在钱包 UI 内**创建、编辑和删除。应用无法通过发送提示来创建策略。典型流程是：在第一次 SIWE 请求时，钱包询问"应用 X 想用你的账户登录"，并提供一个复选框"以后自动登录此网站"。

**硬件钱包**：如果用户必须在设备上按按钮，自动签名就没有意义。如果 `supportsEIP6492` 为 `false`，钱包不得对硬件签名者账户进行自动登录。如果为 `true`，钱包可以在智能账户或 [EIP-7702](/eip-7702/) 账户上使用受限的会话密钥或委托来签名，因为应用可以通过 [ERC-6492](/eip-6492/) 验证这类签名。完成这一设置仍需要一次性的提示。[ERC-7710](/eip-7710/) 是一种可行的委托机制。

钱包可以公开 `wallet_getCurrentAutoLoginPolicy`，让应用检查自己是否可以主动发起登录。

## 示例代码

应用端：如果钱包允许，就发起静默登录。

```ts
const res = await window.ethereum.request({ method: "wallet_getCurrentAutoLoginPolicy" })
  .catch(() => null);                         // method is optional

if (res?.activePolicy) {
  const message = buildSiweMessage({           // your ERC-4361 message builder
    domain: location.host,
    uri: `${location.origin}/login`,
    chainId: 1,
    nonce: await fetchNonce(),
  });
  const signature = await window.ethereum.request({
    method: "personal_sign",
    params: [message, account],
  });
  await verifyOnServer(message, signature);    // no wallet prompt if policy matched
}
```

钱包端：规范参考实现中的匹配检查。

```js
function shouldAutoSign(M, P) {
  if (M.domain !== P.domain) return false;
  if (!M.uri.startsWith(P.uriPrefix)) return false;
  if (!P.allowedChains.includes(M.chainId)) return false;
  if (M.resources && !M.resources.every(r => (P.allowedResources || []).includes(r))) return false;
  if (P.expiresAt !== 0 && Date.now() >= P.expiresAt) return false;
  return true; // plus all standard SIWE validations
}
```

## 需要注意

- 状态为 **Review**；细节仍可能变化。
- 规范建议自动登录**默认关闭**，并提供全局开关以便禁用。
- 请始终将 `domain` 与顶层页面的 origin 比对，这样恶意网站就无法通过嵌入受信任应用的 iframe 触发自动登录。
- 请让 `uriPrefix` 足够具体（例如 `/login` 路径），避免匹配范围过宽。
- 仅涵盖纯文本的 SIWE 消息；EIP-712 类型化数据不在范围内。


---

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