EIPs Explained

ERC-7847 · Draft · ERC · 2024-12-18

ERC-7847: Social Media NFTs

Draft format for publishing Nostr-style signed social posts as NFTs, so any NFT contract, wallet or marketplace can carry and display decentralised social content.

What problem does it solve?

Centralised social platforms can censor, reorder or delete posts. Earlier on-chain social projects usually depended on their own specific set of contracts. ERC-7847 takes a different route: reuse the event format of Nostr, an open protocol where each post is signed by its author's key, and store those events as ordinary NFTs.

Since posts are signed independently of the chain, it does not matter which contract mints them or who owns the token. Every wallet and marketplace that already shows NFTs becomes a place where posts can appear, and anyone can build a feed by indexing them.

How it works

The event. A post has pubkey, created_at, kind, tags and content. Its id is the SHA-256 of this exact JSON serialisation (with strict escaping rules so every implementation gets the same bytes):

[0, "<pubkey hex>", <created_at>, <kind>, <tags>, "<content>"]

The author signs the id with a Schnorr signature on secp256k1 (BIP-340 style, as in Nostr), producing sig.

Kinds. 0 user metadata (name, about, picture), 1 original post or reply, 6 repost. Quote reposts are kind 1 with a q tag.

Tags. Arrays of strings: ["blockchain", chain, contract, tokenId] (recommended), ["e", eventId, relay, marker, pubkey] for replies with markers reply, root or mention, ["p", pubkey] for people involved, ["r", url] for links, and ["imeta", ...] for media.

NFT metadata. The token's description equals content, and every event field (id, pubkey, created_at, kind, sig, content, plus tags) appears in attributes as trait_type/value pairs.

On-chain event. The contract emits PubEvent(id, pubkey, created_at, kind, content, tags, sig) when a post is minted, so indexers can follow posts without reading metadata. Only this event and the metadata format are required.

Sample code

Metadata for a minted post:

{
  "name": "Hello from the chain",
  "description": "gm, first on-chain post",
  "attributes": [
    { "trait_type": "id", "value": "<sha256 of serialized event, hex>" },
    { "trait_type": "pubkey", "value": "<32-byte x-only pubkey, hex>" },
    { "trait_type": "created_at", "value": 1735000000 },
    { "trait_type": "kind", "value": 1 },
    { "trait_type": "sig", "value": "<64-byte schnorr signature, hex>" },
    { "trait_type": "content", "value": "gm, first on-chain post" }
  ]
}

Minimal minting function emitting the required event (ERC-721 based):

event PubEvent(bytes32 id, bytes32 indexed pubkey, uint256 created_at,
               uint32 indexed kind, string content, string tags, string sig);

function createPost(uint256 tokenId, string calldata uri, bytes32 id, bytes32 pubkey,
                    uint256 createdAt, uint32 kind, string calldata content,
                    string calldata tags, string calldata sig) external {
    _safeMint(msg.sender, tokenId);
    _setTokenURI(tokenId, uri);
    emit PubEvent(id, pubkey, createdAt, kind, content, tags, sig);
}

Things to know

  • Status is Draft; the event definition in the spec still has small syntax errors and may change.
  • Authenticity comes from the Schnorr signature over id, not from token ownership. Verifiers must recompute id from the fields and check sig against pubkey.
  • The signing key uses Schnorr/Taproot public keys, not the usual Ethereum address derivation; the spec recommends Nostr tooling (e.g. nostr-tools) to generate keys and sign.
  • With ERC-1155, one token ID should represent one post even if minted in multiple copies.
  • Anyone can mint posts in any contract, so apps must bring their own moderation, blocklists or reputation.

#nft #social #nostr #metadata #erc-721

Details

Authors
Nick Juntilla (@nickjuntilla) <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2024-12-18
Requires

Machine-readable: Markdown · JSON