---
eip: 7866
label: ERC-7866
title: Decentralised User Profiles
status: Review
type: Standards Track
category: ERC
created: 2025-01-22
requires: 165
official: https://eips.ethereum.org/EIPS/eip-7866
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7866.md
canonical: https://eips.huatuo.xyz/zh/eip-7866/
lang: zh
tldr: "提议一种灵魂绑定、不可转让的用户档案，包含用户名、简介、社交账号以及每个 dApp 专属的头像，以 username@chain.soul 标识，并关联到 did:<chain>:<address> 标识符。"
tags: [identity, profiles, sbt, did, avatars]
---

# ERC-7866: Decentralised User Profiles

> Decentralised Interoperable User Identity with segmented Avatars per DApp Profile

**TL;DR:** 提议一种灵魂绑定、不可转让的用户档案，包含用户名、简介、社交账号以及每个 dApp 专属的头像，以 username@chain.soul 标识，并关联到 did:<chain>:<address> 标识符。

## 它解决什么问题？

用户在每个 dApp 中都要重复同样的档案设置：名称、头像、简介、链接。现有方案要么是中心化的（Gravatar），要么绑定在单一链上，要么缺乏按应用定制的能力。ERC-7866 勾勒了一种标准档案：任何链上的任何 dApp 都能读取，由用户掌控，并且可以为每个应用显示不同的头像。

## 它如何运作

**标识符。** 每个档案有：

- 一个便于阅读的句柄 `<username>@<network_slug>.soul`（例如 `alice@eth.soul`），其中用户名在每条链上唯一，`.soul` 表示这是符合本标准的档案；
- 一个去中心化标识符 `did:<chain>:<address>`（例如 `did:ethereum:0x…`）。

**灵魂绑定。** 档案是**灵魂绑定代币**：绑定到某个地址且不可转让，因此无法出售或转移给其他所有者。规范明确否定了为此使用可转让的 [ERC-721](/eip-721/) 代币。

**元数据。** 存储在链下（IPFS 或 Arweave），链上只有 URI。JSON Schema 定义了 `username`、`avatar`、`bio`、`website`、`socials`（Twitter 和 GitHub 的 URL）、`default_avatar_visibility`，以及 `dapp_avatars`，后者是从 dApp 地址到 `{ avatar, visibility }` 的映射。

**可见性。** 每个头像为 `public` 或 `private`。私有头像只返回给用户本人，其他人得到的是错误式的响应。如果某个 dApp 没有自定义头像，则使用默认头像。

**合约。** `ISoulProfile` 提供 `createProfile`、`setDefaultAvatar`、`setDappAvatar`、`getDefaultAvatar` 和 `getDappAvatar`，并为每次变更提供事件。接口检测遵循 [ERC-165](/eip-165/)，作者建议完整部署时采用类似 ENS 的注册表与解析器分离设计（[ERC-137](/eip-137/)）。

## 示例代码

遵循规范 schema 的档案元数据（占位值）：

```json
{
  "username": "alice",
  "avatar": "ipfs://<main-avatar-cid>",
  "bio": "Builder on Ethereum.",
  "website": "https://example.com",
  "socials": {
    "twitter": "https://twitter.com/example",
    "github": "https://github.com/example"
  },
  "default_avatar_visibility": "public",
  "dapp_avatars": {
    "0x1111111111111111111111111111111111111111": {
      "avatar": "ipfs://<game-avatar-cid>",
      "visibility": "public"
    }
  }
}
```

dApp 读取应显示的头像，并回退到默认头像（ethers v6）：

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

const profiles = new Contract(PROFILE_CONTRACT, [
  "function getDefaultAvatar(address) view returns (string, string)",
  "function getDappAvatar(address,address) view returns (string, string)",
], provider);

let [uri, visibility] = await profiles.getDappAvatar(user, MY_DAPP_ADDRESS);
if (!uri) [uri, visibility] = await profiles.getDefaultAvatar(user);
```

## 需要注意

- 状态为 **Review**；接口和 schema 仍可能改变。
- schema 把 `socials.twitter` 和 `socials.github` 设为必填，而参考实现在读取时并不强制执行 `public`/`private` 可见性；请将两者都视为未决问题。
- 参考合约本身没有实现灵魂绑定代币或跨链用户名唯一性；这些留给完整的注册表设计。
- 存储在链上或 IPFS 上的一切内容都是公开的。"private" 可见性只限制合约返回的内容，所以除非已加密，否则不要把敏感数据放进档案元数据。
- 关于基于哈希的最小身份验证注册表，请见 [ERC-7734](/eip-7734/)。


---

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