Coder Social home page Coder Social logo

joaoolucas / example-chat-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xmtp/example-chat-react

0.0 0.0 0.0 1.35 MB

A chat application in React demonstrating the core concepts and capabilities of the XMTP Client SDK.

Home Page: https://xmtp.vercel.app

License: MIT License

JavaScript 3.47% TypeScript 93.70% CSS 2.83%

example-chat-react's Introduction

React Chat Example

Test Lint Build

x-red-sm

Example chat application demonstrating the core concepts and capabilities of the XMTP client SDK

This application is built with React, Next.js, and the xmtp-js client SDK.

Use the application to send and receive messages using the XMTP dev network environment, with some important considerations. You are also free to customize and deploy the application.

This application is maintained by XMTP Labs and distributed under MIT License for learning about and developing applications built with XMTP, a messaging protocol and decentralized communication network for blockchain wallets. The application has not undergone a formal security audit.

Getting Started

Configure Infura

Add your Infura ID to .env.local in the project's root.

NEXT_PUBLIC_INFURA_ID={YOUR_INFURA_ID}

If you do not have an Infura ID, you can follow these instructions to get one.

This example comes preconfigured with an Infura ID provided for demonstration purposes. If you plan to fork or host it, you must use your own Infura ID as detailed above.

Install the package

npm install

Run the development server

npm run dev

Open http://localhost:3000 with your browser to see the application.

Functionality

Wallet Connections

Web3Modal is used to inject a Metamask, Coinbase Wallet, or WalletConnect provider through ethers. Methods for connecting and disconnecting are included in WalletProvider alongside the provider, signer, wallet address, and ENS utilities.

To use the application's chat functionality, the connected wallet must provide two signatures:

  1. A one-time signature that is used to generate the wallet's private XMTP identity
  2. A signature that is used on application start-up to initialize the XMTP client with that identity

Chat Conversations

The application uses the xmtp-js Conversations abstraction to list the available conversations for a connected wallet and to listen for or create new conversations. For each conversation, the application gets existing messages and listens for or creates new messages. Conversations and messages are kept in a lightweight store and made available through XmtpProvider.

Considerations

Here are some important considerations when working with the example chat application:

  • The application sends and receives messages using the XMTP dev network environment. To connect to the production network instead, set the following environment variable NEXT_PUBLIC_XMTP_ENVIRONMENT=production.
    • XMTP may occasionally delete messages and keys from the dev network, and will provide advance notice in the XMTP Discord community (request access). The production network is configured to store messages indefinitely.
  • You can't yet send a message to a wallet address that hasn't used XMTP. The client displays an error when it looks up an address that doesn't have an identity broadcast on the XMTP network.
    • This limitation will soon be resolved by improvements to the xmtp-js library that will allow messages to be created and stored for future delivery, even if the recipient hasn't used XMTP yet.

example-chat-react's People

Contributors

0xlws avatar bhavya2611 avatar jazzz avatar jhaaaa avatar neekolas avatar saulmc avatar snormore 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.