> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monad.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# 如何发布 Farcaster Mini App

发布 Mini App 后,Farcaster 应用中即可发现该应用。但在发布之前,Mini App 必须先托管在某个域名上。

由于 Farcaster 是一个具有多个客户端的去中心化网络,已经采用了一个标准做法:Farcaster 客户端在 Mini App 所托管的域名下查找 `farcaster.json` 文件,以获取有关 Mini App 的信息。

## 托管 `farcaster.json` 文件

`farcaster.json` 必须放在 `/.well-known/farcaster.json` 端点上。

如果您使用的是 [Monad Mini App 模板](https://github.com/monad-developers/monad-miniapp-template/tree/main),可以在发布应用前编辑 [farcaster.json](https://github.com/monad-developers/monad-miniapp-template/blob/main/app/.well-known/farcaster.json/route.ts) 文件,填入您的应用详情!

如果您没有使用该模板,则必须确保您的域名下 `[domain]/.well-known/farcaster.json` 端点上托管了一个 `farcaster.json` 文件。

```ts lines title="app/.well-known/farcaster.json/route.ts" theme={null}
...

const appUrl = process.env.NEXT_PUBLIC_URL;
const farcasterConfig = {
    // accountAssociation details are required to associate the published app with it's author
    // instructions on how to get these values are provided later in this guide.
    accountAssociation: {
        "header": "",
        "payload": "",
        "signature": ""
    },
    frame: {
        version: "1",
        name: "Monad Farcaster Mini App Template", // Name of your Mini App
        iconUrl: `${appUrl}/images/icon.png`, // Icon of the app in the app store
        homeUrl: `${appUrl}`, // Default launch URL
        imageUrl: `${appUrl}/images/feed.png`, // Default image to show if shared in a feed.
        screenshotUrls: [], // Visual previews of the app
        tags: ["monad", "farcaster", "miniapp", "template"], // Descriptive tags for search
        primaryCategory: "developer-tools",
        buttonTitle: "Launch Template",
        splashImageUrl: `${appUrl}/images/splash.png`, // URL of image to show on loading screen.	
        splashBackgroundColor: "#ffffff", // Hex color code to use on loading screen.
        webhookUrl: `${appUrl}/api/webhook` // Webhook url for notifications
    }
};

...
```

以上示例是 `farcaster.json` 文件的部分呈现。[farcaster.json](https://github.com/monad-developers/monad-miniapp-template/blob/main/app/.well-known/farcaster.json/route.ts) 文件的完整参考可以在 [此处](https://miniapps.farcaster.xyz/docs/guides/publishing#define-your-application-configuration) 找到。

## 使用 Farcaster 移动应用生成 `accountAssociation`

[farcaster.json](https://github.com/monad-developers/monad-miniapp-template/blob/main/app/.well-known/farcaster.json/route.ts) 文件中的 `accountAssociation` 对象用于将 Mini App 与发布者的 Farcaster 账户进行关联。

您可以使用 Farcaster 移动应用来生成 `accountAssociation` 对象。

进入 `Settings(位于 Developer 下方) > Domains`,输入托管 Mini App 的域名并点击 `Generate Domain Manifest`。

<Accordion title="看不到 Developer 选项?">
  要让 `Developer` 选项可见,您需要在 Farcaster 中启用 `Developer mode`。

  您可以通过 `Settings(位于 Profile and Account 下方) > Advanced > 向下滚动并启用 Developer mode` 来开启它。

  <iframe style={{ aspectRatio: "16 / 9" }} src="https://www.youtube.com/embed/BcXOjl88ft8?si=T3eicQi_kkeSuJ1e" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen />
</Accordion>

生成的 `accountAssociation` 对象将复制到您的剪贴板中,您可以将其中的值粘贴到 [farcaster.json](https://github.com/monad-developers/monad-miniapp-template/blob/main/app/.well-known/farcaster.json/route.ts) 文件中。

```ts lines title="app/.well-known/farcaster.json/route.ts" theme={null}
...

const appUrl = process.env.NEXT_PUBLIC_URL;
const farcasterConfig = {
    accountAssociation: {
        header: "eyJmaWQiOjE3OTc5LCJ0eXBlIjoiY3VzdG9keSIsImtleSI6IjB4MGMxNWE5QkVmRTg3RjY0N0IwMDNhMjI0MTY4NDYwMzYyODQ0M2Y4YiJ9",
        payload: "eyJkb21haW4iOiJtb25hZC1taW5pYXBwLXRlbXBsYXRlLXNldmVuLnZlcmNlbC5hcHAifQ",
        signature: "MHgwYzY2NDdjZDhjOWJiY2JmYzg2NGIzZjVjYWVjY2ExMTdlOTY4ZGQwMWIzMmM0NGViMjU5ZDhlOGQyMzdhZTZiMDU1MmNmNWRiMDU1MDMwNTZmNTNhZmEwZDZlZTBlZmIyMmJmNDNmMDQ4NTdhMzk2NmY0YmMzODk2N2NlZDI5ZjFi"
    },
    ...
};

...
```

<iframe style={{ aspectRatio: "16 / 9" }} src="https://www.youtube.com/embed/zDCms51Hxcw?si=IlaAmxvBjoJMTB2k" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen />

您可以在 [此处](https://github.com/monad-developers/monad-miniapp-template/blob/main/app/.well-known/farcaster.json/route.ts) 找到 Monad Mini App Template 应用的 `farcaster.json` 文件。

一旦托管好 `farcaster.json` 文件,您的 Mini App 就可以在 Farcaster 应用中被发现,您可以在 Farcaster 应用中搜索该 Mini App 来测试它!
