Skip to content

Integration Options

Typescript SDK

You can use our TypeScript SDK @ecp.eth/sdk to access data on chain, comments from the indexer or interact with the contract.

Installation

npm
npm install @ecp.eth/sdk
# install required peer dependencies
npm install viem wagmi @tanstack/react-query @tanstack/query-core

Examples

Fetch comments

import { fetchComments } from "@ecp.eth/sdk/indexer";
 
console.log("fetching comments...");
 
const comments = await fetchComments({
  // the url of indexer api
  apiUrl: "https://api.ethcomments.xyz",
  // the uri of commenting target - replace with your own url to limit comments to a specific page
  targetUri: "https://demo.ethcomments.xyz",
});
 
console.log(
  "here is a list of comments for https://demo.ethcomments.xyz",
  comments,
);

The response is a list of comments and pagination information, see IndexerAPIListCommentsSchemaType.

API reference

Fetch replies

import { fetchCommentReplies } from "@ecp.eth/sdk/indexer";
 
// fetch replies for a comment based on its id
const replies = await fetchCommentReplies({
  apiUrl: "https://api.ethcomments.xyz",
  commentId:
    "0xdce24de208a5e15b6b9b7e7c1ccdc5c08d8a7d8ab20c37c60e1d96a2aa1f9941",
});
API reference

Create a comment

CommentForm reference code

API reference

SDK Reference

For more details about the SDK functionality, check out our SDK Reference.