Skip to main content

Get started with XMTP

The XMTP message API revolves around a network client that allows retrieving and sending messages to other network participants.

A client must be connected to a wallet on startup. If this is the very first time the client is created, the client will generate a key bundle that is used to encrypt and authenticate messages.

The key bundle persists encrypted in the network using a wallet signature. The public side of the key bundle is also regularly advertised on the network to allow parties to establish shared encryption keys.


This is an overview of the core concepts and lines of code needed to use XMTP successfully.

import { Client } from "@xmtp/xmtp-js";
import { Wallet } from "ethers";

// You'll want to replace this with a wallet from your application
const signer = Wallet.createRandom();
// Create the client with your wallet. This will connect to the XMTP development network by default
const xmtp = await Client.create(signer, { env: "dev" });
// Start a conversation with XMTP
const conversation = await xmtp.conversations.newConversation(
// Load all messages in the conversation
const messages = await conversation.messages();
// Send a message
await conversation.send("gm");
// Listen for new messages in the conversation
for await (const message of await conversation.streamMessages()) {
console.log(`[${message.senderAddress}]: ${message.content}`);


To start with XMTP, install the XMTP client SDK:

yarn install @xmtp/xmtp-js

Need to send a test message?

Message this XMTP message bot to get an immediate automated reply:

  • gm.xmtp.eth (0x937C0d4a6294cdfa575de17382c7076b579DC176)


  • If you run into issues with Buffer and polyfills, see these solutions

Was the information on this page helpful?
powered by XMTP