---
eip: 4972
label: ERC-4972
title: Name-Owned Account
status: Draft
type: Standards Track
category: ERC
created: 2022-04-04
requires: 137
official: https://eips.ethereum.org/EIPS/eip-4972
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-4972.md
canonical: https://eips.huatuo.xyz/zh/eip-4972/
lang: zh
tldr: 为 ENS 类名称服务中的每个名称提供各自确定性的智能合约账户，由名称所有者控制，使资产和数据可以跟随名称，并在名称转让时一并转移。
tags: [ens, naming, account, identity, create2]
---

# ERC-4972: Name-Owned Account

> Name-Owned Account for Social Identity

**TL;DR:** 为 ENS 类名称服务中的每个名称提供各自确定性的智能合约账户，由名称所有者控制，使资产和数据可以跟随名称，并在名称转让时一并转移。

## 它解决什么问题？

像 `alice.eth` 这样的名称会解析到一个地址，但名称本身不持有任何东西。如果 Alice 出售或转让这个名称，所有资产或声誉仍然绑定在她把名称指向的那个地址上，而不是名称上。

ERC-4972 提出了**名称所有账户（Name-Owned Account，NOA）**：属于名称节点本身的智能合约账户。谁拥有名称，谁就控制该账户。转让名称，账户及其中的一切也随之转移。它还为每个名称持有者提供了一个现成的智能合约账户，作者希望这有助于合约账户的普及。

## 它如何运作

所有权链条是：*名称所有者 → 名称节点（[ERC-137](/eip-137/)）→ 被拥有的账户*。

有两个小接口：

- 名称服务注册表公开 `ownedAccount(bytes32 node) → address`，即给定名称节点对应的 NOA。
- NOA 公开 `name() → bytes32`（其名称节点）和 `nameService() → address`（名称所在的注册表），这样任何人都能从账户追溯到它的名称，并查看当前的所有者。

创建：由工厂（可以就是名称服务本身）使用 `CREATE2`（[EIP-1014](/eip-1014/)）部署 NOA，使用相同的 init code，并以**名称节点作为盐值（salt）**。这使得从名称到账户的映射是一对一且确定性的，因此在账户部署之前就能知道它的地址。

NOA 实际能*做*什么（执行调用、持有代币、验证签名）由具体实现决定。

## 示例代码

规范中的接口，以及工厂如何推导地址：

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

interface INameServiceRegistry {
    function ownedAccount(bytes32 node) external view returns (address);
}

interface INameOwnedAccount {
    function name() external view returns (bytes32);
    function nameService() external view returns (address);
}

abstract contract NOAFactory is INameServiceRegistry {
    bytes32 public immutable initCodeHash; // hash of the shared NOA init code

    constructor(bytes32 h) { initCodeHash = h; }

    function ownedAccount(bytes32 node) public view returns (address) {
        return address(uint160(uint256(keccak256(
            abi.encodePacked(bytes1(0xff), address(this), node, initCodeHash)
        ))));
    }
}
```

在链下计算 ENS 风格的名称节点（ethers v6）：

```ts
import { namehash } from "ethers";
const node = namehash("alice.eth"); // bytes32 passed to ownedAccount(node)
```

## 需要注意

- 状态为 **Draft**：接口可能变化，规范也没有定义权威的部署。
- NOA 自身的权限模型（执行前如何检查当前名称所有者）没有规定；实现必须正确处理，因为过期或错误的所有者检查会把控制权交给错误的一方。
- 购买带有 NOA 的名称，实际上也买下了其中的内容；买家和市场应当检查该账户。
- NFT 方面的类似思路是 [ERC-6551](/eip-6551/)（代币绑定账户）；通用智能账户请参阅 [ERC-4337](/eip-4337/)。


---

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