Comments are kind 1111 events that can reply to any event, addressable event, or external content like a URL (NIP-22). Each comment tags both the thread root (uppercase E/A/I tags) and the item it replies to (lowercase tags), so nested replies stay attached to the original content.
store.comments(parent) returns every comment replying directly to an event or CommentPointer. Cast them with Comment to read their pointers and engagement.
To build the event yourself, use CommentFactory. create() and reply() take a parent event, rumor, or CommentPointer, and .group() scopes the comment to a NIP-29 group.
Pass the full comment event when replying to a comment, since a pointer can't carry the root tags. setParent() throws when given a pointer to a comment.
Comments
Comments are kind 1111 events that can reply to any event, addressable event, or external content like a URL (NIP-22). Each comment tags both the thread root (uppercase
E/A/Itags) and the item it replies to (lowercase tags), so nested replies stay attached to the original content.Reading comments
store.comments(parent)returns every comment replying directly to an event orCommentPointer. Cast them withCommentto read their pointers and engagement.store.comments()is shorthand forstore.model(CommentsModel, parent).NoteandTorrentcasts also exposecomments$.Walking a comment thread
The
Commentcast resolves the root content and the parent being replied to. Both resolve toundefinedfor external roots like URLs.comment.reactions$andcomment.zaps$return the comment's reactions and zaps.Posting a comment
The
CreateCommentaction signs a comment and publishes it to the parent author's inboxes and the user's outboxes.To build the event yourself, use
CommentFactory.create()andreply()take a parent event, rumor, orCommentPointer, and.group()scopes the comment to a NIP-29 group.Pass the full comment event when replying to a comment, since a pointer can't carry the root tags.
setParent()throws when given a pointer to a comment.Helpers
getCommentRootPointer(comment)andgetCommentReplyPointer(comment)parse and cache the root and replyCommentPointerisValidComment(event)checks for kind 1111 with both pointers, which the cast requiresisCommentEventPointer,isCommentAddressPointer, andisCommentExternalPointernarrow aCommentPointercreateCommentTagsForEvent(parent)andcreateCommentTagsFromCommentPointer(pointer, root)build the tagsExample: Comment feed
Best Practices
NoteFactory.reply()CreateCommentover the factory so the parent's author sees the reply#e,#a, or#ifilter before reading them, since the model only reads the store