Alert Source Discuss
Standards Track: ERC

ERC-5570: 数字收据非同质化代币

作为实物购买数字收据的非同质化代币,其中元数据表示 JSON 收据

Authors Sean Darcy (@darcys22)
Created 2022-09-01
Requires EIP-721

摘要

本 ERC 提出了一种用于交易数字收据的标准模式。数字收据非同质化代币由供应商在客户从其商店购买商品时发行,并包含记录保存所需的交易详细信息。数字收据非同质化代币扩展了 ERC-721,允许管理和拥有独特的代币。

动机

来自在线零售商的购买包含通过电子邮件发送和/或以物理方式提供给客户的收据。这些收据至关重要,原因有很多,但它们以模拟形式提供,金融系统难以解析。尽管销售点系统已经是数字化的,并且客户通常希望在自己的数字系统中获得这些信息,但数字收据从未获得吸引力。因此,我们留下了一个冗余的数字 -> 模拟 -> 数字过程,该过程需要不必要的数据录入或使用笨拙的收据扫描应用程序。

数字收据相对简单,可以使用可以解析为 JSON 或其他结构化格式的模式来指定。此外,我们可以通过使用供应商的私钥对收据进行数字签名来证明收据的有效性。

随着以太坊的扩展,需要开发工具来为最终用户提供法定货币交易已经具备的功能(例如收据)。NFT 提供了一个独特的机会,可以通过交易状态更新将链上购买与其交易详细信息直接链接起来。如果我们从概念上将交易视为提供给一个参与者的资金和提供给另一个参与者的商品,那么我们的现实生活状态包括交易的两个方面,1) 资金改变所有权,2) 商品改变所有权。NFT 收据是交易的一等公民,反映了作为交易状态一部分的商品所有权变更。它们将使我们的链上交易状态与现实世界中发生的变化保持一致。

通过交易状态直接链接到交易收据的便利性非常重要,其他将收据分发到链下或与初始交易分离的智能合约的方法会丢失此链接,并迫使最终用户在需要时手动查找交易详细信息。 通过比较允许用户点击交易以查看其收据(购买后立即可用,无需任何进一步操作)的钱包与需要搜索数据存储以查找他们在钱包历史记录中看到的交易收据的用户,可以证明其优势。

作为 NFT 的数字收据也可以在概念上包括其他重要信息,例如商品序列号和交付跟踪等。

完全自动化我们的金融世界的主要障碍之一是难以跟踪交易详细信息。人类以物理方式跟踪纸质收据非常过时,而区块链上的 NFT 为显着改进这些系统提供了一条途径。

规范

交易流程:

  • 客户从在线零售商处购买商品,结账会引导客户选择铸造 NFT。
  • 智能合约为用户提供数字收据非同质化代币。
  • 在完成订单时,零售商会将下面 JSON 模式中指定的数字收据作为元数据上传到之前铸造的 NFT。

数字收据 JSON 模式

JSON 模式由 2 部分组成。根模式包含收据的高级详细信息(例如日期和供应商),另一个模式用于收据中包含的可选的重复行项目。

根模式

{
  "id": "receipt.json#",
  "description": "Receipt Schema for Digital Receipt Non-Fungible Tokens",
  "type": "object",
  "required": ["name", "description", "image", "receipt"],
  "properties": {
    "name": {
      "title": "Name",
      "description": "Identifies the token as a digital receipt",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "description": "Brief description of a digital receipt",
      "type": "string"
    },
    "receipt": {
      "title": "Receipt",
      "description": "Details of the receipt",
      "type": "object",
      "required": ["id", "date", "vendor", "items"],
      "properties": {
        "id": {
          "title": "ID",
          "description": "Unique ID for the receipt generated by the vendor",
          "type": "string"
        },
        "date": {
          "title": "Date",
          "description": "Date Receipt Issued",
          "type": "string",
          "format": "date"
        },
        "vendor": {
          "title": "Vendor",
          "description": "Details of the entity issuing the receipt",
          "type": "object",
          "required": ["name", "website"],
          "properties": {
            "name": {
              "title": "Name",
              "description": "Name of the vendor. E.g. Acme Corp",
              "type": "string"
            },
            "logo": {
              "title": "Logo",
              "description": "URL of the issuer's logo",
              "type": "string",
              "format": "uri"
            },
            "address": {
              "title": "Address",
              "description": "List of strings comprising the address of the issuer",
              "type": "array",
              "items": { "type": "string" },
              "minItems": 2,
              "maxItems": 6
            },
            "website": {
              "title": "Website",
              "description": "URL of the issuer's website",
              "type": "string",
              "format": "uri"
            },
            "contact": {
              "title": "Contact Details",
              "description": "Details of the person to contact",
              "type": "object",
              "required": [],
              "properties": {
                "name": {
                  "title": "Name",
                  "description": "Name of the contact person",
                  "type": "string"
                },
                "position": {
                  "title": "Position",
                  "description": "Position / Role of the contact person",
                  "type": "string"
                },
                "tel": {
                  "title": "Telephone Number",
                  "description": "Telephone number of the contact person",
                  "type": "string"
                },
                "email": {
                  "title": "Email",
                  "description": "Email of the contact person",
                  "type": "string",
                  "format": "email"
                },
                "address": {
                  "title": "Address",
                  "description": "List of strings comprising the address of the contact person",
                  "type": "array",
                  "items": { "type": "string" },
                  "minItems": 2,
                  "maxItems": 6
                }
              }
            }
          }
        },
        "items": {
          "title": "Items",
          "description": "Items included into the receipt",
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "item.json#"
          }
        },
        "comments": {
          "title": "Comments",
          "description": "Any messages/comments the issuer wishes to convey to the customer",
          "type": "string"
        }
      }
    },
    "image": {
      "title": "Image",
      "description": "Viewable/Printable Image of the Digital Receipt",
      "type": "string"
    },
    "signature": {
      "title": "Signature",
      "description": "Digital signature by the vendor of receipts data",
      "type": "string"
    },
    "extra": {
      "title": "Extra",
      "description": "Extra information about the business/receipt as needed",
      "type": "string"
    }
  }
}

行项目模式

{
  "type": "object",
  "id": "item.json#",
  "required": ["id", "title", "date", "amount", "tax", "quantity"],
  "properties": {
    "id": {
      "title": "ID",
      "description": "Unique identifier of the goods or service",
      "type": "string"
    },
    "title": {
      "title": "Title",
      "description": "Title of the goods or service",
      "type": "string"
    },
    "description": {
      "title": "Description",
      "description": "Description of the goods or service",
      "type": "string"
    },
    "link": {
      "title": "Link",
      "description": "URL link to the web page for the product or sevice",
      "type": "string",
      "format": "uri"
    },
    "contract": {
      "title": "Contract",
      "description": "URL link or hash to an external contract for this product or service",
      "type": "string"
    },
    "serial_number": {
      "title": "Serial Number",
      "description": "Serial number of the item",
      "type": "string"
    },
    "date": {
      "title": "Supply Date",
      "description": "The date the goods or service were provided",
      "type": "string",
      "format": "date"
    },
    "amount": {
      "title": "Unit Price",
      "description": "Unit Price per item (excluding tax)",
      "type": "number"
    },
    "tax": {
      "title": "Tax",
      "description": "Amount of tax charged for unit",
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "rate", "amount"],
        "properties": {
          "name": {
            "title": "Name of Tax",
            "description": "GST/PST etc",
            "type": "string"
          },
          "rate": {
            "title": "Tax Rate",
            "description": "Tax rate as a percentage",
            "type": "number"
          },
          "amount": {
            "title": "Tax Amount",
            "description": "Total amount of tax charged",
            "type": "number"
          }
        }
      }
    },
    "quantity": {
      "title": "Quantity",
      "description": "Number of units",
      "type": "integer"
    }
  }
}

理由

引入的模式符合 ERC-721 的元数据扩展,方便地允许以前用于查看 NFT 的工具显示我们的收据。新属性“receipt”包含我们新提供的收据结构,签名属性可以选择允许供应商对收据结构进行数字签名。

向后兼容性

此标准是 ERC-721 的扩展。它与 ERC-721 中提到的可选扩展元数据和可枚举兼容。

安全考虑

数字收据中存储的数据包括各种类型的个人身份信息 (PII),例如供应商的姓名、联系方式和购买的商品。PII 是可用于识别、定位或联系个人的敏感信息。保护客户的隐私至关重要,因为未经授权访问 PII 可能会导致身份盗窃、欺诈或其他恶意活动。

为确保客户的隐私,必须加密数字收据中包含的 PII。通过加密 PII,只有具有相应解密密钥的授权方才能访问和读取数字收据中存储的信息。这确保了客户的隐私得到保护,并且他们的数据免受潜在的滥用。

虽然加密 PII 至关重要,但需要注意的是,定义特定的加密标准超出了此 ERC 的范围。

版权

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

Citation

Please cite this document as:

Sean Darcy (@darcys22), "ERC-5570: 数字收据非同质化代币," Ethereum Improvement Proposals, no. 5570, September 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5570.