Skip to content

Commit

Permalink
docs: XMTP Kit update (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriguespe committed May 4, 2024
1 parent 249e1ac commit 5e595f3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
4 changes: 4 additions & 0 deletions site/docs/pages/xmtp/get-xmtp-frame-message.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ async function getResponse(req: any): Promise<NextResponse> {
if (isXmtpFrameRequest(body)) {
const { isValid, message } = await getXmtpFrameMessage(body); // [!code focus]
// ... do something with the message if isValid is true
if (isValid) {
const { verifiedWalletAddress } = message;
// ... do something with the verifiedWalletAddress
}
} else {
// ...
}
Expand Down
42 changes: 33 additions & 9 deletions site/docs/pages/xmtp/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
---
title: Introduction to XMTP Kit · OnchainKit
deescription: Introduction to XMTP Kit
description: Introduction to XMTP Kit
---

# Introduction to XMTP Kit

XMTP Kit is designed to be modular and flexible, allowing developers to use only the parts of the protocol that they need.
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.

```ts
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 use **XMTP Kit** you must also install `@xmtp/frames-validator` in your app, alongside Onchainkit.
In order to get the `verifiedWalletAddress` you must install `@xmtp/frames-validator` in your Frame, alongside Onchainkit.

:::code-group

Expand All @@ -25,12 +55,6 @@ pnpm add @coinbase/onchainkit @xmtp/frames-validator

:::

[XMTP](https://xmtp.org/) is a wallet to wallet messaging protocol, and many XMTP client applications are adding Frames support.

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`.

You can learn more about how XMTP works with frames in [their documentation here](https://xmtp.org/docs/build/frames).

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

- [XMTP Kit](/xmtp/introduction)
Expand Down

0 comments on commit 5e595f3

Please sign in to comment.