---
eip: 7409
label: ERC-7409
title: Public Non-Fungible Tokens Emote Repository
status: Final
type: Standards Track
category: ERC
created: 2023-07-26
requires: 165
official: https://eips.ethereum.org/EIPS/eip-7409
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7409.md
canonical: https://eips.huatuo.xyz/zh/eip-7409/
lang: zh
tldr: 一个单一的公共仓库合约，任何人都可以用 Unicode 表情符号对任意 NFT 做出反应，让每个合集（无论新旧）都能获得链上的点赞和反应，而无需修改自身代码。
tags: [nft, social, reactions, emoji, erc721]
---

# ERC-7409: Public Non-Fungible Tokens Emote Repository

> React to any Non-Fungible Tokens using Unicode emojis.

**TL;DR:** 一个单一的公共仓库合约，任何人都可以用 Unicode 表情符号对任意 NFT 做出反应，让每个合集（无论新旧）都能获得链上的点赞和反应，而无需修改自身代码。

## 它解决什么问题？

人们希望像对待帖子一样对 NFT 做出反应：点赞、爱心、火焰表情。如今这些都发生在各个市场的链下，因此反应彼此割裂，容易伪造，NFT 合约本身也看不到。

ERC-7409 把反应放到一个共享的、无需许可的链上仓库中。由于仓库与合集是分开的，它适用于任何 [ERC-721](/eip-721/) 或 [ERC-1155](/eip-1155/) 代币，包括在该标准出现之前很久就已部署的合集。合集随后可以在此基础上构建各种机制，例如收集到足够多反应后会进化的代币。

它取代了 [ERC-6381](/eip-6381/)，后者把表情符号存储为 `bytes4`。带肤色和变体选择符的表情符号放不进 4 个字节，所以 ERC-7409 改用 `string`。除此之外，两者在功能上是一样的。

## 它如何运作

仓库针对每个 `(collection, tokenId, emoji)` 存储一个计数，以及哪些地址使用过该表情。

- `emote(collection, tokenId, emoji, state)` 添加（`true`）或移除（`false`）你的反应。每个地址对每个代币的每个表情最多只能有一个有效反应。设置为已有的状态不会产生任何效果。
- `emoteCountOf(collection, tokenId, emoji)` 返回计数；`hasEmoterUsedEmote` 检查某一个地址。
- `bulkEmote`、`bulkEmoteCountOf` 和 `haveEmotersUsedEmotes` 对多个代币一次性完成同样的操作。
- `presignedEmote` 允许他人使用你对 `(DOMAIN_SEPARATOR, collection, tokenId, emoji, state, deadline)` 的 ECDSA 签名来提交你的反应。domain separator 包含链 ID 和仓库地址，因此签名无法在另一条链上重放。
- 每次状态变化都会触发 `Emoted(emoter, collection, tokenId, emoji, on)`。

仓库不会检查代币是否存在。规范定义了一个以 `0x3110735`（"EMOTES"）开头的靓号地址，目标是在每条链上都相同：`0x3110735F0b8e71455bAe1356a33e428843bCb9A1`。它的 ERC-165 接口 id 是 `0x1b3327ab`。

## 示例代码

接口节选：

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

interface IERC7409 {
    event Emoted(address indexed emoter, address indexed collection, uint256 indexed tokenId, string emoji, bool on);

    function emoteCountOf(address collection, uint256 tokenId, string memory emoji) external view returns (uint256);
    function hasEmoterUsedEmote(address emoter, address collection, uint256 tokenId, string memory emoji) external view returns (bool);
    function emote(address collection, uint256 tokenId, string memory emoji, bool state) external;
}
```

做出反应并读取计数（ethers v6）：

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

const repo = new Contract(
  "0x3110735F0b8e71455bAe1356a33e428843bCb9A1",
  [
    "function emote(address,uint256,string,bool)",
    "function emoteCountOf(address,uint256,string) view returns (uint256)",
  ],
  signer,
);

await (await repo.emote(collection, 42n, "🔥", true)).wait();
console.log(await repo.emoteCountOf(collection, 42n, "🔥"));
```

## 需要注意

- 状态为 Final。
- 在依赖这个固定地址之前，请确认仓库确实已部署在你使用的链上。
- `emoji` 字段可以是任意字符串。鼓励使用 Unicode 表情符号，但也允许自定义值；前端必须自行决定如何渲染它们。视觉上相似的表情符号如果字节序列不同，会被分开计数。
- 预签名消息在截止时间之前一直有效，可能被重放，从而重新添加你之后已移除的反应。请使用较短的截止时间。
- 反应可以免费发出（gas 除外），且每个地址只能一个，因此计数衡量的是地址而不是人。请把它当作一个弱信号。


---

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