Dado-2
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.
Getting Started
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:
- A one-time signature that is used to generate the wallet's private XMTP identity
- 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 theproduction
network instead, set the following environment variableNEXT_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). Theproduction
network is configured to store messages indefinitely.
- XMTP may occasionally delete messages and keys from the
- 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.
- This limitation will soon be resolved by improvements to the