---
eip: 5313
label: ERC-5313
title: Light Contract Ownership
status: Final
type: Standards Track
category: ERC
created: 2022-07-22
requires: 165, 173
official: https://eips.ethereum.org/EIPS/eip-5313
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5313.md
canonical: https://eips.huatuo.xyz/zh/eip-5313/
lang: zh
tldr: 最小的所有权接口：合约公开 owner()，让市场和工具能够知道谁控制着它。
tags: [ownership, access-control, interface, nft, marketplaces]
---

# ERC-5313: Light Contract Ownership

> An interface for identifying ownership of contracts

**TL;DR:** 最小的所有权接口：合约公开 owner()，让市场和工具能够知道谁控制着它。

## 它解决什么问题？

第三方网站，尤其是 NFT 市场，需要知道谁控制着某个合约：例如，让合集所有者编辑其页面、设置横幅或配置版税。此前的既有方案是 [EIP-173](/eip-173/)，它同时规范了 `transferOwnership` 和 `OwnershipTransferred` 事件。许多合约公开了 `owner()`，但处理转移的方式不同（两步转移、由多签控制、不可变的所有者），因此无法声称完全符合 EIP-173。

ERC-5313 把大家早已依赖的那部分固定下来：一个 `owner()` 视图函数。

## 它如何运作

合规的合约只需实现这一个函数：

```solidity
interface EIP5313 {
    /// @notice Get the address of the owner
    function owner() external view returns (address);
}
```

仅此而已。没有转移函数，没有事件，并且刻意不定义 [ERC-165](/eip-165/) 接口 ID，这样许多已有 `owner()` 的现有合约无需修改即可合规。每个 EIP-173 合约（包括 OpenZeppelin 的 `Ownable`）都自动满足 ERC-5313。

所有权如何设置、转移或放弃，完全由合约自行决定。

## 示例代码

一个所有者固定的合约，EIP-173 无法涵盖它，因为它不能转移：

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

contract FixedOwnerCollection {
    address private immutable _owner;

    constructor() { _owner = msg.sender; }

    /// ERC-5313
    function owner() external view returns (address) {
        return _owner;
    }
}
```

通过脚本检查控制权（ethers v6）：

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

const provider = new JsonRpcProvider(process.env.RPC_URL);
const c = new Contract(collection, ["function owner() view returns (address)"], provider);
const owner: string = await c.owner();
const isOwner = owner.toLowerCase() === userAddress.toLowerCase();
```

## 需要注意

- 状态：**Final**。
- 没有 ERC-165，你就无法确定 `owner()` 指的是"控制者"：合约可能有一个签名相同但毫不相干的函数。对于"这个钱包是否可以编辑合集页面"这类低风险检查没有问题，但对于把有价值的资产发送给所报告的所有者这类决定则有风险。
- `owner()` 返回零地址按惯例表示所有权已被放弃，但规范并不要求这种解释。
- 如果你需要标准化的转移语义和事件，请改为实现 [EIP-173](/eip-173/)；这样你自然也满足 ERC-5313。


---

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