Alert Source Discuss
⚠️ Draft Standards Track: ERC

ERC-6785: ERC-721 实用程序信息扩展

通过函数和 NFT 的元数据,提供对 NFT `utility` 信息的简易访问

Authors Otniel Nicola (@OT-kthd), Bogdan Popa (@BogdanKTHD)
Created 2023-03-27
Discussion Link https://ethereum-magicians.org/t/eip-6785-erc-721-utilities-extension/13568
Requires EIP-165, EIP-721

摘要

本规范定义了标准函数和元数据模式的扩展,概述了 token 的 utility 包括什么,以及如何使用和/或访问该 utility。 本规范是 ERC-721 的可选扩展。

动机

本规范旨在阐明与 NFT 相关的 utility 是什么,以及如何访问此 utility。 依靠第三方平台获取有关自己拥有的 NFT 的 utility 的信息可能会导致诈骗、 网络钓鱼或其他形式的欺诈。

目前,与 NFT 一起提供的实用程序未在链上捕获。我们希望 NFT 的 utility 成为 NFT 元数据的一部分。元数据信息将包括:a) utility 类型,b) utility 描述,c) utility 的频率和持续时间,以及 d) utility 的到期时间。这将提供关于 utility 条款的透明度,并增加创建者兑现这些 utility 的责任。

由于有关如何访问给定 utility 的说明可能会随着时间的推移而发生变化,因此应该有一个关于这些更改的历史记录,以提高透明度。

规范

本文档中的关键词“MUST”、“MUST NOT”、“REQUIRED”、“SHALL”、“SHALL NOT”、“SHOULD”、“SHOULD NOT”、“RECOMMENDED”、“MAY”和“OPTIONAL” 按照 RFC 2119 中的描述进行解释。

每个符合 ERC-6785 的合约都 MUST 实现如下定义的接口:

合约接口

// @title NFT Utility description
///  Note: the EIP-165 identifier for this interface is ed231d73

interface IERC6785 {

    // Logged when the utility description URL of an NFT is changed
    /// @notice Emitted when the utilityURL of an NFT is changed
    /// The empty string for `utilityUri` indicates that there is no utility associated
    event UpdateUtility(uint256 indexed tokenId, string utilityUri);

    /// @notice set the new utilityUri - remember the date it was set on
    /// @dev The empty string indicates there is no utility
    /// Throws if `tokenId` is not valid NFT
    /// @param utilityUri  The new utility description of the NFT
    /// 4a048176
    function setUtilityUri(uint256 tokenId, string utilityUri) external;

    /// @notice Get the utilityUri of an NFT
    /// @dev The empty string for `utilityUri` indicates that there is no utility associated
    /// @param tokenId The NFT to get the user address for
    /// @return The utility uri for this NFT
    /// 5e470cbc
    function utilityUriOf(uint256 tokenId) external view returns (string memory);

    /// @notice Get the changes made to utilityUri
    /// @param tokenId The NFT to get the user address for
    /// @return The history of changes to `utilityUri` for this NFT
    /// f96090b9
    function utilityHistoryOf(uint256 tokenId) external view returns (string[] memory);
}

所有定义为 view 的函数 MAY 被实现为 pure 或 view

函数 setUtilityUri MAY 被实现为 public 或 external。此外,设置 utilityUri 的能力 SHOULD 仅限于提供 utility 的人,无论是 NFT 创建者还是其他人。

当调用 setUtilityUri 函数或 token 的 utility 发生任何其他更改时(例如批量更新),MUST 发出 UpdateUtility 事件。

utilityHistoryOf 方法 MUST 反映对 tokenId 的 utilityUri 所做的所有更改,无论这些更改是通过 setUtilityUri 完成的,还是通过任何其他方式(例如批量更新)完成的。

当使用 ed231d73 调用时,supportsInterface 方法 MUST 返回 true

原始元数据 SHOULD 符合 “ERC-6785 Metadata with utilities JSON Schema”,它是 ERC-721 中定义的 “ERC-721 Metadata JSON Schema” 的兼容扩展。

“ERC-6785 Metadata with utilities JSON Schema” :

{
  "title": "Asset Metadata",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Identifies the asset to which this NFT represents"
    },
    "description": {
      "type": "string",
      "description": "Describes the asset to which this NFT represents"
    },
    "image": {
      "type": "string",
      "description": "A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
    },
    "utilities": {
      "type": "object",
      "required": [
        "type",
        "description",
        "t&c"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "Describes what type of utility this is"
        },
        "description": {
          "type": "string",
          "description": "A brief description of the utility"
        },
        "properties": {
          "type": "array",
          "description": "An array of possible properties describing the utility, defined as key-value pairs",
          "items": {
            "type": "object"
          }
        },
        "expiry": {
          "type": "number",
          "description": "The period of time for the validity of the utility, since the minting of the NFT. Expressed in seconds"
        },
        "t&c": {
          "type": "string",
          "description": ""
        }
      }
    }
  }
}

理由

由于 utilityUri 可能包含必须限制在一定级别的信息,并且可能依赖于链下工具来显示所述信息,因此创建者需要能够在链下工具或平台变得不可用或无法访问时对其进行修改。

出于透明目的,拥有 utilityHistoryOf 方法将清楚地说明 utilityUri 如何随时间变化。

例如,如果创建者出售一个 NFT,该 NFT 授予持有者与创建者进行视频通话的权利,则此 utility NFT 的元数据将如下所示:

{
  "name": "...",
  "description": "...",
  "image": "...",
  "utilities": {
    "type": "Video call",
    "description": "I will enter a private video call with whoever owns the NFT",
    "properties": [
      {
        "sessions": 2
      },
      {
        "duration": 30
      },
      {
        "time_unit": "minutes"
      }
    ],
    "expiry": 1.577e+7,
    "t&c": "https://...."
  }
}

为了获得进入视频通话所需的详细信息,所有者将访问他们拥有的 NFT 的 getUtilityUri 方法返回的 URI。 此外,访问详细信息可能需要通过拥有 NFT 的钱包进行身份验证。

utility 的当前状态也包含在 URI 中(例如:还有多少会话可用等)

向后兼容性

此标准与当前的 ERC-721 标准兼容。没有其他标准为 NFT 定义类似的方法,并且方法名称未被其他 ERC-721 相关标准使用。

测试用例

测试用例可在此处获得 here

参考实现

参考实现可以在 here 找到。

安全注意事项

没有与本标准的实施直接相关的安全注意事项。

版权

版权和相关权利通过 CC0-1.0 放弃。

Citation

Please cite this document as:

Otniel Nicola (@OT-kthd), Bogdan Popa (@BogdanKTHD), "ERC-6785: ERC-721 实用程序信息扩展 [DRAFT]," Ethereum Improvement Proposals, no. 6785, March 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6785.