ERC-7847 Social media post NFT (Social Media NFTs)
Draft · NFTs & multi-token · created 2024-12-18
A standard that embeds Nostr-style signed events in NFT metadata, allowing decentralized, censorship-resistant social media posts to be published permanently on a blockchain.
Why it is needed
In existing social media, posts are stored on centralized platform servers, letting the operator delete, censor, or manipulate them at will, and if an account is suspended the author may lose access to their own posts. Decentralized social protocols such as Nostr have emerged, but they rely on relay servers outside the blockchain, so persistence and censorship resistance depend on the goodwill of relay operators. Meanwhile, attempts to post content on-chain each use different contract structures and data formats, so wallets and marketplaces can only recognize them as generic NFTs and cannot interpret them as social posts. Without a standardized format, there is also no way to aggregate posts from different projects into a single feed or establish a common method for verifying authenticity via the author's signature.
What to implement
event PubEvent( bytes32 id, bytes32 indexed pubkey, uint256 created_at, uint32 indexed kind, string content, string tags, string sig, );: An event emitted when a new post is created, recording the id, author's public key, creation time, kind, content, tags, and signature.event PubEvent( bytes32 id, bytes32 indexed pubkey, uint256 created_at, uint32 indexed kind, string content, string tags, string sig );: The same PubEvent is also used when posting a reply; kind is likewise 1, and tags includes reply-related e and p tags.function createPost( uint256 tokenId, string uri, bytes32 id, bytes32 pubkey, uint256 created_at, uint32 kind, string content, string tags, string sig ) public { mint(tokenId, uri); emit PubEvent(id, pubkey, created_at, kind, content, tags, sig); }: A reference implementation function that mints the token and then emits a PubEvent to announce the publication of the post.
In depth
id derivation rule
The id is the sha256 hash of the structure [0, pubkey (lowercase hex), created_at (Unix seconds), kind (number), tags (array of string arrays), content (string)] serialized as UTF-8 JSON. To prevent different implementations from producing different ids, the following rules must be followed: trim leading and trailing whitespace, collapse whitespace within tags to a single space, and escape newlines (\n), double quotes (\"), backslashes (\\), carriage returns (\r), tabs (\t), backspaces (\b), and form feeds (\f) within content.
kind values
kind 0 is user metadata, containing a JSON string of the form {name, about, picture} in content, with additional fields allowed; relays may delete the previous event when a new event with the same pubkey arrives. kind 1 is original content (including replies), which can include short text along with on-chain and off-chain references to other media or events. Reposts use kind 6.
Tag system
The blockchain tag ("blockchain", chain name/id, contract, token_id) is a recommended tag; token_id can be omitted if unknown before minting. The imeta tag attaches multiple media items with dim, url, and m values, the e tag references other posts, the p tag lists related public keys, and the r tag holds external URLs.
Metadata JSON mapping
Event fields are stored as trait_type/value pairs in the attributes array of the NFT metadata. Every attribute other than id, pubkey, created_at, kind, sig, and content is treated as an event tag. description must be identical to content, and image, animation_url, and external_url are linked respectively to the imeta image, multimedia, and r tag references.
Key generation and signing
The private key can be any Ethereum private key or mnemonic as long as it is a 32-byte hex string, and it can also be generated with a command such as openssl rand -hex 32. The public key follows Bitcoin's BIP 341 (Taproot+Schnorr) scheme, and the signature is a Schnorr signature over the secp256k1 curve, computing the public nonce (R), challenge (e), and signature (s) from the private key, message, and a random nonce (k). Using a tool such as nostr-tools is recommended.
PubEvent and reference structure
PubEvent (id, pubkey, created_at, kind, content, tags, sig) is the common event used for both new posts and replies. A reply's e tag takes the form [event-id, relay-url, marker, pubkey], where marker distinguishes "reply", "root", and "mention", and the p tag holds the list of public keys involved in the reply thread. Quote reposts are distinguished from thread replies by attaching a q tag ([event-id, relay-url, pubkey, blockchain-name-or-id]) to a kind 1 event.
Compatibility with ERC-721/1155
In ERC-721, each post must have a unique tokenId, while in ERC-1155 the same tokenId may be minted multiple times but must represent only a single post event. Because this is added on top of existing NFT standards, it remains compatible with existing NFTs, and only clients that understand this standard additionally interpret them as social posts.
A proposal that has not yet been finalized
This proposal is currently in Draft status and has not yet been finalized; details may change or discussion may stall.
Things to watch out for
- Data integrity: Forgery can only be prevented if the id is derived exactly according to the specified serialization rule. Who owns the NFT is irrelevant to the authenticity of the post as long as the signature is valid.
- Spam and moderation: Platforms built on this standard must implement their own moderation layer, blocklists, and reputation systems, because both event-based social media and NFTs allow anyone to create content.