Giter VIP home page Giter VIP logo

chat-sdk's Introduction

banner

Chat SDK for Boson Protocol v2

๐Ÿ› ๏ธ Tools for building on top of the Boson Protocol.

JS lib which extends @xmtp/xmtp-js, adding support for chat threads and further message types.


Install

npm i @bosonprotocol/chat-sdk

Usage

  • Initialise SDK
    • import { BosonXmtpClient } from "@bosonprotocol/chat-sdk";
      const client = await BosonXmtpClient.initialise(signer, "test");
  • Get Chat Threads
    • const counterparties = ["0xabc123", "0xdef456", ...];
      const threads = await client.getThreads(counterparties);
  • Send Message
    • const messageObj = {
        threadId: {
          exchangeId: "1",
          buyerId: "2",
          sellerId: "3"
        },
        contentType: MessageType.String,
        version: "0.0.1",
        content: {
          value: "Example message"
        }
      };
      const recipient = "0xabc123...";
      await client.encodeAndSendMessage(messageObj, recipient);
  • Monitor Chat Thread (i.e. for incoming messages)
    • for await (const message of await client.monitorThread(threadId, counterparty)) {
        console.log(message);
      }

Local Development

  • Build
    • npm run build
  • Test
    • npm run test:all
      npm run test:unit
      npm run test:integration
  • Lint
    • npm run lint
      npm run lint:fix
  • Format
    • npm run prettier

chat-sdk's People

Contributors

albertfolch-redeemeum avatar dennisfurrer avatar dohaki avatar github-actions[bot] avatar levalleux-ludo avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.