---
eip: 2193
label: ERC-2193
title: dType Alias Extension - Decentralized Type System
status: Stagnant
type: Standards Track
category: ERC
created: 2019-07-16
requires: 155, 1900, 2157
official: https://eips.ethereum.org/EIPS/eip-2193
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2193.md
canonical: https://eips.huatuo.xyz/zh/eip-2193/
lang: zh
tldr: 提议为任何链上数据记录提供人类可读的别名，例如 alice@socialnetwork.profile，基于 dType 类型注册表构建，而不是 DNS 风格的名称。
tags: [naming, alias, registry, dtype]
---

# ERC-2193: dType Alias Extension - Decentralized Type System

> We are proposing Alias - a semantic standard for identifying on-chain resources by human-readable qualifiers, supporting any type of data.

**TL;DR:** 提议为任何链上数据记录提供人类可读的别名，例如 alice@socialnetwork.profile，基于 dType 类型注册表构建，而不是 DNS 风格的名称。

## 它解决什么问题？

[ENS（EIP-137）](/eip-137/)为账户和合约提供人类可读的名称，但无法为合约内部的单条数据命名，比如某个用户的个人资料或某条支付通道。ENS 还沿用了 DNS 从叶到根的顺序（`sub.domain.eth`），这与点号在大多数编程语言中的含义正好相反。

ERC-2193 提议建立一个 **Alias** 注册表，为通过 dType 系统存储的任何记录命名（类型定义见 [ERC-1900](/eip-1900/)，存储合约见 [ERC-2157](/eip-2157/)），并使用带有含义的分隔符。

## 它如何运作

- 别名由 dType 类型标识符、分隔符、`name`，以及该类型存储合约中记录的 `identifier` 组合而成。
- 分隔符及其阅读顺序：

| 分隔符 | 含义 | 示例 |
| --- | --- | --- |
| `.` | 一般域名，从根到叶 | `domain.subdomain.resource` |
| `@` | 与参与者相关的数据，从叶到根 | `alice@socialnetwork.profile` |
| `#` | 概念，从根到叶 | `topicX#postY` |
| `/` | 资源路径，从根到叶 | `resourceRoot/resource` |

- 只要拥有 dType 存储合约中的底层记录，任何人都可以设置别名。他们用一个签名来证明这一点，签名覆盖类型 id、identifier、name、分隔符、`nonce`、Alias 合约地址和链 id（[EIP-155](/eip-155/)），以防止重放。
- 所有者可以更新或删除别名。一条记录可以有多个使用不同名称或分隔符的别名。
- 内容既可以用原始的 `bytes32` 标识符寻址，也可以用人类可读的别名寻址，两者解析到同一条记录。

## 示例代码

规范中的接口：

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface Alias {
    event AliasSet(bytes32 dtypeIdentifier, bytes1 separator, string name, bytes32 indexed identifier);

    function setAlias(
        bytes32 dtypeIdentifier,
        bytes1 separator,
        string memory name,
        bytes32 identifier,
        bytes memory signature
    ) external;

    function getAliased(bytes1 separator, string memory name) external view returns (bytes32 identifier);
}
```

在脚本中解析别名（ethers v6）：

```ts
const id = await aliasRegistry.getAliased("0x40", "alice"); // "@" separator
```

## 需要注意

- 状态：**Stagnant**，它所依赖的 dType 提案（[ERC-1900](/eip-1900/)、[ERC-2157](/eip-2157/)）也是如此。
- 确切的签名编码、向后兼容性和测试用例都没有规定（"将会补充"）。
- 它只适用于存放在与 dType 关联的合约中的数据，实际上并不能作为 ENS 的通用替代品。


---

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