Skip to content

Comment

The Comment is a data structure that contains the essential information of a comment.

content

The comment content stores the plain text content of the comment.

  • Please use \n for line breaks. (Most browsers will normalize the line breaks to \n regardless of the OS).
  • any media or links that should be displayed to users should be stored in the content property and rendered by clients based on the media type at the uri.

metadata

The metadata property stores additional data that shouldn't be shown to the user as it is.

targetUri

It serves as a unique identifier for locating comments.

Be careful when choosing the value for the targetUri property as an inconsistent targetUri will result in some comments missing from the indexer response.

  • Any URIs, as long as it is a unique string that follows the RFC 3986 standard.

  • If your web page is dynamic and accepts query parameters, you should carefully consider which parameters are necessary to locate the correct comments. As a general rule:

    1. Normalize the URL, e.g. using normalize-url.
    2. Sort the query parameters using sortQueryParameters from normalize-url.
    3. Do not include query parameters unrelated to page content, such as tracking or feature flags.
  • If the comment is a reply to a comment then set the value to undefined.

App/Chain Agnostic URIs

Whenver possible, it is recommended to use app or chain agnostic URIs, e.g. CAIP-19 specification for referencing onchain or offchain assets. This ensures the reference is consistent and maximal compatibility across different applications and chains.

Example (NFT and collection):

chain://eip155:1/erc721:0xa723a8a69d9b8cf0bc93b92f9cb41532c1a27f8f/11
chain://eip155:1/erc721:0xa723a8a69d9b8cf0bc93b92f9cb41532c1a27f8f

parentId

The parentId property is used to store the parent comment id.

  • If the comment is a reply to a comment, set the parentId to the id of the parent comment.
  • If the comment is a top-level comment, leave it undefined.

author

The author property is used to store the author's address. It is the address of the account that created and owns the comment.

app

The app property is used to store the app signer's address. The app signer represents the the owner of the app or community. If you are creating features just for yourself to post, such as a blog, you can use your own address as the app.

To see detailed explanation please refer to the Dual-signature System page.

deadline

The deadline is a timestamp in seconds since the epoch. Posting a comment with an expired deadline will result in the transaction being reverted.

  • It must be a future timestamp.
  • It provides a guarantee around the timestamp when the user or app countersigned the comment.

commentType

The commentType property is used to categorize the type of comment being created.

  • Must be a string value that describes the nature of the comment.
  • Common examples include:
    • "comment" - A standard comment or discussion
    • "like" - A like or reaction to content
  • Applications can define their own comment types based on their specific use cases.
  • This field helps applications filter and display comments appropriately based on their type.

channelId

The channelId property is used to organize comments into different channels or categories.

  • Must be a numeric identifier (uint256).
  • Allows applications to segment comments into different groups, communities, or topics.
  • Comments with the same channelId are logically grouped together.
  • Applications can use this to implement features like multiple comment sections, communities, or discussion boards.

createdAt (automatic)

  • Timestamp when the comment was first created (in seconds since epoch).
  • Set automatically when the comment is posted to the blockchain.
  • Cannot be modified after creation.

updatedAt (automatic)

  • Timestamp when the comment was last modified (in seconds since epoch).
  • Updated automatically whenever the comment content or metadata is edited.
  • Initially equals createdAt for new comments.

hookData

The hookData property stores additional data that can be added by hooks during comment processing.

  • Must be a valid string.
  • Used by the protocol's hook system to attach additional information to comments.
  • The specific format and content depend on the hooks implemented by the application.
  • Applications can use this for custom features like moderation flags, additional metadata, or integration data.