EIPs Explained

ERC-7409 · Final · ERC · 2023-07-26

ERC-7409: Public Non-Fungible Tokens Emote Repository

A single public repository contract where anyone can react to any NFT with a Unicode emoji, giving every collection, old or new, on-chain likes and reactions without changing its own code.

What problem does it solve?

People want to react to NFTs the way they react to posts: likes, hearts, fire emojis. Today that happens off-chain on individual marketplaces, so reactions are siloed, easy to fake and invisible to the NFT contract itself.

ERC-7409 puts reactions on-chain in one shared, permissionless repository. Because the repository is separate from the collection, it works for any ERC-721 or ERC-1155 token, including collections deployed long before the standard existed. Collections can then build mechanics on top, such as a token that evolves after collecting enough reactions.

It supersedes ERC-6381, which stored emojis as bytes4. Emojis with skin tones and variation selectors do not fit in 4 bytes, so ERC-7409 uses string instead. Otherwise the two are functionally the same.

How it works

The repository stores, per (collection, tokenId, emoji), a count and which addresses have used that emoji.

  • emote(collection, tokenId, emoji, state) adds (true) or removes (false) your reaction. Each address can have at most one active reaction per emoji per token. Setting an existing state does nothing.
  • emoteCountOf(collection, tokenId, emoji) returns the count; hasEmoterUsedEmote checks one address.
  • bulkEmote, bulkEmoteCountOf and haveEmotersUsedEmotes do the same for many tokens at once.
  • presignedEmote lets someone else submit your reaction using your ECDSA signature over (DOMAIN_SEPARATOR, collection, tokenId, emoji, state, deadline). The domain separator includes the chain id and repository address, so signatures cannot be replayed on another chain.
  • Every state change emits Emoted(emoter, collection, tokenId, emoji, on).

The repository does not check that the token exists. The spec defines a vanity address starting with 0x3110735 ("EMOTES") intended to be the same on every chain: 0x3110735F0b8e71455bAe1356a33e428843bCb9A1. Its ERC-165 interface id is 0x1b3327ab.

Sample code

Interface excerpt:

// 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;
}

Reacting and reading the count (ethers v6):

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, "🔥"));

Things to know

  • Status is Final.
  • Before relying on the fixed address, confirm the repository is actually deployed on the chain you use.
  • The emoji field is any string. Unicode emojis are encouraged, but custom values are allowed; front ends must decide how to render them. Different byte sequences for visually similar emojis count separately.
  • A presigned message stays valid until its deadline and can be replayed to re-add a reaction you later removed. Use short deadlines.
  • Reactions are free to give (gas aside) and one per address, so counts measure addresses, not people. Treat them as a soft signal.

#nft #social #reactions #emoji #erc721

Details

Authors
Bruno Škvorc (@Swader), Steven Pineda (@steven2308), Stevan Bogosavljevic (@stevyhacker), Jan Turk (@ThunderDeliverer)
Status
Final
Type
Standards Track / ERC
Created
2023-07-26
Requires

Machine-readable: Markdown · JSON