Skip to content

Introduction to XMTP utilities

OnchainKit has a collection of utilities that allows you to build Frames with the XMTP protocol.

Metadata

To build a Frame with XMTP, you must first add XMTP metadata. This is done using the getFrameMetadata function.

const frameMetadata = getFrameMetadata({
  /**
   * Frame metadata like Image, Buttons, Input, etc.
   */
  isOpenFrame: true,
  accepts: { xmtp: 'vNext' },
});
 
export const metadata: Metadata = {
  /**
   * ...other metadata
   */
  other: {
    ...frameMetadata,
  },
};
  • isOpenFrame: A boolean that indicates whether the Frame is open or not.
  • accepts: An object that indicates the versions of the Frame that the Frame supports.

Handling XMTP Frames

When a user interacts with a Frame inside an XMTP client application, you will need to handle the payload slightly differently from an interaction coming from Farcaster. The primary identifier for a user on Farcaster is the fid, while in XMTP it is the verifiedWalletAddress.

In order to get the verifiedWalletAddress you must install @xmtp/frames-validator in your Frame, alongside Onchainkit.

npm
npm install @coinbase/onchainkit @xmtp/frames-validator

To assist you in handling interactions from XMTP, and extracting the verifiedWalletAddress from a POST payload, here is the XMTP utilities which includes: