### Example: Start Video Recording with Permissions Source: https://miniapps.farcaster.xyz/llms-full.txt Demonstrates how to request camera and microphone permissions before attempting to access media devices for video recording. ```typescript import { sdk } from '@farcaster/miniapp-sdk' async function startVideoRecording() { try { // Request permissions first await sdk.actions.requestCameraAndMicrophoneAccess() // Now you can access getUserMedia const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }) // Use the stream for video recording const videoElement = document.querySelector('video') if (videoElement) { videoElement.srcObject = stream } } catch (error) { if (error instanceof Error && error.name === 'NotAllowedError') { // Permissions were denied alert('Camera and microphone access is required for video recording') } else { console.error('Failed to start recording:', error) } } } ``` -------------------------------- ### Install @farcaster/mini-app-solana Source: https://miniapps.farcaster.xyz/llms-full.txt Install the Solana Mini App SDK using npm, pnpm, or yarn. ```bash npm install @farcaster/mini-app-solana ``` ```bash pnpm add @farcaster/mini-app-solana ``` ```bash yarn add @farcaster/mini-app-solana ``` -------------------------------- ### Example Client Context Object Source: https://miniapps.farcaster.xyz/docs/sdk/context An example of the client context object, showing platform, FID, and insets. ```json > sdk.context.client { platformType: "mobile", clientFid: 9152, added: true, safeAreaInsets: { top: 0, bottom: 20, left: 0, right: 0, }; notificationDetails: { url: "https://api.farcaster.xyz/v1/frame-notifications", token: "a05059ef2415c67b08ecceb539201cbc6" } } ``` -------------------------------- ### Install Farcaster MiniApp SDK with yarn Source: https://miniapps.farcaster.xyz/llms-full.txt Install the MiniApp SDK for existing projects using yarn. ```bash yarn add @farcaster/miniapp-sdk ``` -------------------------------- ### Example User Context Object Source: https://miniapps.farcaster.xyz/docs/sdk/context An example of the user context object returned by the SDK. ```json > sdk.context.user { "fid": 6841, "username": "deodad", "displayName": "Tony D\'Addeo", "pfpUrl": "https://i.imgur.com/dMoIan7.jpg", "bio": "Building @warpcast and @farcaster, new dad, like making food", "location": { "placeId": "ChIJLwPMoJm1RIYRetVp1EtGm10", "description": "Austin, TX, USA" } } ``` -------------------------------- ### Example ClientFeatures Object Source: https://miniapps.farcaster.xyz/docs/sdk/context An example of the `context.features` object, showing that haptics and camera/microphone access are available and granted. ```javascript > sdk.context.features { haptics: true, cameraAndMicrophoneAccess: true } ``` -------------------------------- ### Install Farcaster MiniApp SDK with pnpm Source: https://miniapps.farcaster.xyz/llms-full.txt Install the MiniApp SDK for existing projects using pnpm. ```bash pnpm add @farcaster/miniapp-sdk ``` -------------------------------- ### Launcher Location Context Example Source: https://miniapps.farcaster.xyz/docs/sdk/context Example of the location context when a Mini App is launched directly via the launcher. ```javascript > sdk.context.location { type: "launcher" } ``` -------------------------------- ### Install cloudflared Source: https://miniapps.farcaster.xyz/docs/guides/sharing Installs the cloudflared command-line tool using Homebrew. This is a prerequisite for exposing a local server. ```bash brew install cloudflared ``` -------------------------------- ### Farcaster Mini App Manifest Example Source: https://miniapps.farcaster.xyz/docs/specification An example of the manifest metadata required for distributing a Farcaster Mini App. ```json { "version": "1", "name": "Yoink!", "iconUrl": "https://yoink.party/logo.png", "homeUrl": "https://yoink.party/framesV2/", "imageUrl": "https://yoink.party/framesV2/opengraph-image", "buttonTitle": "🚩 Start", "splashImageUrl": "https://yoink.party/logo.png", "splashBackgroundColor": "#f5f0ec", "webhookUrl": "https://yoink.party/api/webhook" } ``` -------------------------------- ### Open Mini App Location Context Example Source: https://miniapps.farcaster.xyz/docs/sdk/context Example of the location context when a Mini App is launched from another Mini App. ```javascript > sdk.context.location { type: "open_miniapp", referrerDomain: "example-app.com" } ``` -------------------------------- ### Launcher Location Context Example Source: https://miniapps.farcaster.xyz/llms-full.txt Example of the `location` context when a Mini App is launched directly by the client app, not from a specific Farcaster context. Indicates a direct launch. ```typescript > sdk.context.location { type: "launcher" } ``` -------------------------------- ### Account Association Example Source: https://miniapps.farcaster.xyz/docs/specification An example of a Farcaster Signature for account association, verifying domain ownership. ```json { "header": "eyJmaWQiOjM2MjEsInR5cGUiOiJjdXN0b2R5Iiwia2V5IjoiMHgyY2Q4NWEwOTMyNjFmNTkyNzA4MDRBNkVBNjk3Q2VBNENlQkVjYWZFIn0", "payload": "eyJkb21haW4iOiJ5b2luay5wYXJ0eSJ9", "signature": "D7urCIelYBtFc12UkEw/VOE1rkGKMdmDqAP/6s7sLWNfjhyug8pQCTM68XVJ8Gal6eBZxvtFE4RpVwqDtnLrzhs=" } ``` -------------------------------- ### Create New Mini App Project Source: https://miniapps.farcaster.xyz/docs/getting-started Use the create-mini-app CLI to quickly scaffold a new Farcaster Mini App project. This command initiates an interactive setup process. ```bash npm create @farcaster/mini-app ``` -------------------------------- ### Example: Token Approval and Swap using Batch Transactions Source: https://miniapps.farcaster.xyz/docs/guides/wallets Demonstrates how to use `useSendCalls` to first approve a token allowance and then execute a swap in a single batched transaction. Note that transactions execute sequentially and are not atomic. ```javascript import { useSendCalls } from 'wagmi' import { encodeFunctionData, parseUnits } from 'viem' function ApproveAndSwap() { const { sendCalls } = useSendCalls() const handleApproveAndSwap = () => { sendCalls({ calls: [ // Approve USDC { to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', data: encodeFunctionData({ abi: erc20Abi, functionName: 'approve', args: ['0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', parseUnits('100', 6)] }) }, // Swap USDC for ETH { to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', data: encodeFunctionData({ abi: uniswapAbi, functionName: 'swapExactTokensForETH', args: [/* swap parameters */] }) } ] }) } return ( ) } ``` -------------------------------- ### Install Farcaster Solana Package Source: https://miniapps.farcaster.xyz/docs/guides/solana Install the necessary package for Solana wallet integration in your Farcaster Mini App. ```bash npm install @farcaster/mini-app-solana ``` -------------------------------- ### Open Mini App Location Context Example Source: https://miniapps.farcaster.xyz/llms-full.txt Example of the `location` context when a Mini App is launched from another Mini App using the `openMiniApp` action. Includes the `referrerDomain` for tracking. ```typescript > sdk.context.location { type: "open_miniapp", referrerDomain: "example-app.com" } ``` -------------------------------- ### Example Client Context Data Source: https://miniapps.farcaster.xyz/llms-full.txt An example of the client context object as it might be returned by `sdk.context.client`. It shows platform type, client FID, added status, and safe area insets. ```json > sdk.context.client { platformType: "mobile", clientFid: 9152, added: true, safeAreaInsets: { top: 0, bottom: 20, left: 0, right: 0, }; notificationDetails: { url: "https://api.farcaster.xyz/v1/frame-notifications", token: "a05059ef2415c67b08ecceb539201cbc6" } } ``` -------------------------------- ### Install and Use LTS Node.js Version Source: https://miniapps.farcaster.xyz/docs/getting-started If you are using an unsupported Node.js version, update to the latest LTS version using `nvm`. This is a common solution for installation and build failures. ```bash nvm install --lts nvm use --lts ``` -------------------------------- ### Example User Context Data Source: https://miniapps.farcaster.xyz/llms-full.txt An example of the user context object as it might be returned by `sdk.context.user`. It includes details like FID, username, display name, profile picture, bio, and location. ```json > sdk.context.user { "fid": 6841, "username": "deodad", "displayName": "Tony D\'Addeo", "pfpUrl": "https://i.imgur.com/dMoIan7.jpg", "bio": "Building @warpcast and @farcaster, new dad, like making food", "location": { "placeId": "ChIJLwPMoJm1RIYRetVp1EtGm10", "description": "Austin, TX, USA" } } ``` -------------------------------- ### Example: Sending a Notification Source: https://miniapps.farcaster.xyz/llms-full.txt An example implementation for sending a notification. This code demonstrates how to construct and send the POST request to the Farcaster notification endpoint. ```typescript import { NextResponse } from 'next/server'; import { env } from '@/env.mjs'; export const POST = async (req: Request) => { const { token, notificationId, title, body, targetUrl } = await req.json(); const response = await fetch(`${env.FARCASTER_API_URL}/notifications`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${env.FARCASTER_API_KEY}`, }, body: JSON.stringify({ tokens: [token], notification: { notificationId, title, body, }, targetUrl, }), }); const data = await response.json(); return NextResponse.json(data); }; ``` -------------------------------- ### Selection Haptic Feedback Examples Source: https://miniapps.farcaster.xyz/llms-full.txt Provides examples for triggering selection haptic feedback, suitable for UI element selections or toggling states. ```typescript import { sdk } from '@farcaster/miniapp-sdk' // When user selects an item from a list await sdk.haptics.selectionChanged() // When toggling a switch await sdk.haptics.selectionChanged() ``` -------------------------------- ### Install Farcaster MiniApp SDK (npm) Source: https://miniapps.farcaster.xyz/docs/getting-started Install the Farcaster MiniApp SDK into an existing project using npm. This provides the necessary tools to integrate Farcaster features into your web application. ```bash npm install @farcaster/miniapp-sdk ``` -------------------------------- ### Implement a Mini App Hub Source: https://miniapps.farcaster.xyz/llms-full.txt Provides an example of creating a hub application that lists and allows users to open multiple other Mini Apps. It includes basic error handling for each open action. ```typescript const miniApps = [ { name: 'Farville', url: 'https://farcaster.xyz/miniapps/WoLihpyQDh7w/farville' }, { name: 'Bountycaster', url: 'https://www.bountycaster.xyz' }, { name: 'Yoink', url: 'https://yoink.party/framesV2/' } ] function MiniAppHub() { const handleOpenApp = async (url: string) => { try { await sdk.actions.openMiniApp({ url }) } catch (error) { console.error('Failed to open app:', error) } } return (
{miniApps.map(app => ( ))}
) } ``` -------------------------------- ### Install Mini App Wagmi Connector Source: https://miniapps.farcaster.xyz/llms-full.txt Install the necessary Wagmi connector for Farcaster Mini Apps. This connector facilitates interaction with the user's wallet. ```bash npm install @farcaster/miniapp-wagmi-connector ``` ```bash pnpm add @farcaster/miniapp-wagmi-connector ``` ```bash yarn add @farcaster/miniapp-wagmi-connector ``` -------------------------------- ### Farcaster Mini App Manifest and Embed Example Paths Source: https://miniapps.farcaster.xyz/llms-full.txt Illustrates the typical file paths for a Farcaster Mini App manifest and its associated embeds across different pages on a domain. ```text myapp.com/.well-known/farcaster.json ← Manifest myapp.com/game/123 ← Page with embed myapp.com/leaderboard ← Page with embed myapp.com/profile/456 ← Page with embed ``` -------------------------------- ### Example Farcaster Mini App Manifest Source: https://miniapps.farcaster.xyz/docs/specification This is a valid `farcaster.json` manifest file. It includes account association details and configuration for the Mini App itself, such as its name, URLs, and webhook. ```json { "accountAssociation": { "header": "eyJmaWQiOjM2MjEsInR5cGUiOiJjdXN0b2R5Iiwia2V5IjoiMHgyY2Q4NWEwOTMyNjFmNTkyNzA4MDRBNkVBNjk3Q2VBNENlQkVjYWZFIn0", "payload": "eyJkb21haW4iOiJ5b2luay5wYXJ0eSJ9", "signature": "MHgwZmJiYWIwODg3YTU2MDFiNDU3MzVkOTQ5MDRjM2Y1NGUxMzVhZTQxOGEzMWQ5ODNhODAzZmZlYWNlZWMyZDYzNWY4ZTFjYWU4M2NhNTAwOTMzM2FmMTc1NDlmMDY2YTVlOWUwNTljNmZiNDUxMzg0Njk1NzBhODNiNjcyZWJjZTFi" }, "miniapp": { "version": "1", "name": "Yoink!", "iconUrl": "https://yoink.party/logo.png", "homeUrl": "https://yoink.party/framesV2/", "imageUrl": "https://yoink.party/framesV2/opengraph-image", "buttonTitle": "🚩 Start", "splashImageUrl": "https://yoink.party/logo.png", "splashBackgroundColor": "#f5f0ec", "webhookUrl": "https://yoink.party/api/webhook" } } ``` -------------------------------- ### View a Cast by Author and Hash Source: https://miniapps.farcaster.xyz/docs/sdk/actions/view-cast This example demonstrates viewing a cast by providing both its hash and the author's username. This can be useful for disambiguation or if the author's username is readily available. ```javascript // View a cast by author and hash await sdk.actions.viewCast({ hash: "0x78c086e5", authorUsername: "six", }); ``` -------------------------------- ### Import and Use quickAuth.getToken Source: https://miniapps.farcaster.xyz/docs/sdk/quick-auth/get-token Import the SDK and call `quickAuth.getToken` to get a session token. This is the primary way to authenticate users in your Farcaster Mini App. ```javascript import { sdk } from '@farcaster/miniapp-sdk' const { token } = await sdk.quickAuth.getToken() ``` -------------------------------- ### Handle User Rejection for signManifest Source: https://miniapps.farcaster.xyz/docs/sdk/actions/sign-manifest This example demonstrates how to catch and handle the `RejectedByUser` error that may occur if a user denies the manifest signing request. ```javascript try { await sdk.experimental.signManifest({ domain: 'example.com' }) } catch (error) { if (error instanceof SignManifest.RejectedByUser) { // Handle user rejection } } ``` -------------------------------- ### View a Cast and Close the Mini App Source: https://miniapps.farcaster.xyz/docs/sdk/actions/view-cast This example shows how to view a cast and automatically close the mini app afterward by setting the 'close' parameter to true. ```javascript // View a cast and close the mini app await sdk.actions.viewCast({ hash: "0x6a112e2d35e2d2008e25dd29811e8769d1edd9ca", close: true, }); ``` -------------------------------- ### Example ClientFeatures Object Source: https://miniapps.farcaster.xyz/llms-full.txt Illustrates a typical features object returned by the SDK, showing enabled features. ```typescript > sdk.context.features { haptics: true, cameraAndMicrophoneAccess: true } ``` -------------------------------- ### Encode URL for Preview Tool Source: https://miniapps.farcaster.xyz/docs/guides/agents-checklist This example demonstrates how to encode a URL for use with the Farcaster preview tool. It uses Python to URL-encode the provided mini-app URL, which is then used to construct the preview tool URL. ```bash # Encode your URL encoded_url=$(python3 -c "import urllib.parse; print(urllib.parse.quote('https://example.com/page'))") echo "https://farcaster.xyz/~/developers/mini-apps/preview?url=$encoded_url" ``` -------------------------------- ### Mini App Embed Schema Example Source: https://miniapps.farcaster.xyz/docs/specification This JSON object demonstrates the structure for embedding a Mini App, including version, image URL, and button configuration with action details. ```json { "version": "1", "imageUrl": "https://yoink.party/framesV2/opengraph-image", "button": { "title": "🚩 Start", "action": { "type": "launch_frame", "name": "Yoink!", "url": "https://yoink.party/framesV2", "splashImageUrl": "https://yoink.party/logo.png", "splashBackgroundColor": "#f5f0ec" } } } ``` -------------------------------- ### Get Supported Capabilities Source: https://miniapps.farcaster.xyz/docs/sdk/detecting-capabilities Use `sdk.getCapabilities()` to retrieve a list of all supported SDK methods. This is useful for checking if specific features like composing casts or accessing wallet providers are available. ```typescript import { sdk } from '@farcaster/miniapp-sdk' // Get all supported capabilities const capabilities = await sdk.getCapabilities() // Check for specific capabilities const supportsCompose = capabilities.includes('actions.composeCast') const supportsWallet = capabilities.includes('wallet.getEthereumProvider') // Check for haptics support const supportsHaptics = { impact: capabilities.includes('haptics.impactOccurred'), notification: capabilities.includes('haptics.notificationOccurred'), selection: capabilities.includes('haptics.selectionChanged') } // Use capabilities conditionally if (supportsHaptics.impact) { await sdk.haptics.impactOccurred('medium') } ``` -------------------------------- ### Validate JWT Session Token on Backend Source: https://miniapps.farcaster.xyz/llms-full.txt Install `@farcaster/quick-auth` on your backend and use `client.verifyJwt` to validate a JWT. The payload contains the user's FID in the `sub` property. This example uses Hono for the backend framework. ```ts import { Errors, createClient } from '@farcaster/quick-auth' import { Hono } from 'hono' import { cors } from 'hono/cors' import { createMiddleware } from 'hono/factory' import { HTTPException } from 'hono/http-exception' const client = createClient() const app = new Hono<{ Bindings: Cloudflare.Env }>() // Resolve information about the authenticated Farcaster user. In practice // you might get this information from your database, Neynar, or Snapchain. async function resolveUser(fid: number) { const primaryAddress = await (async () => { const res = await fetch( `https://api.farcaster.xyz/fc/primary-address?fid=${fid}&protocol=ethereum`, ) if (res.ok) { const { result } = await res.json<{ result: { address: { fid: number protocol: 'ethereum' | 'solana' address: string } } }>() return result.address.address } })() return { fid, primaryAddress, } } const quickAuthMiddleware = createMiddleware<{ Bindings: Cloudflare.Env Variables: { user: { fid: number primaryAddress?: string } } }>(async (c, next) => { const authorization = c.req.header('Authorization') if (!authorization || !authorization.startsWith('Bearer ')) { throw new HTTPException(401, { message: 'Missing token' }) } try { const payload = await client.verifyJwt({ token: authorization.split(' ')[1] as string, domain: c.env.HOSTNAME, }) const user = await resolveUser(payload.sub) c.set('user', user) } catch (e) { if (e instanceof Errors.InvalidTokenError) { console.info('Invalid token:', e.message) throw new HTTPException(401, { message: 'Invalid token' }) } throw e } await next() }) app.use(cors()) app.get('/me', quickAuthMiddleware, (c) => { return c.json(c.get('user')) }) export default app ``` -------------------------------- ### Import and Use quickAuth.fetch Source: https://miniapps.farcaster.xyz/docs/sdk/quick-auth/fetch Import the sdk and use the quickAuth.fetch function to make an authenticated request. This requires a URL as input. ```javascript import { sdk } from '@farcaster/miniapp-sdk' await sdk.quickAuth.fetch(url) ``` -------------------------------- ### Notification Location Context Example Source: https://miniapps.farcaster.xyz/docs/sdk/context Example of the location context when a Mini App is launched from a notification. ```javascript > sdk.context.location { type: "notification", notification: { notificationId: "f7e9ebaf-92f0-43b9-a410-ad8c24f3333b" title: "Yoinked!", body: "horsefacts captured the flag from you.", } } ``` -------------------------------- ### Preconnect to Quick Auth Server Source: https://miniapps.farcaster.xyz/docs/sdk/quick-auth Add a `preconnect` hint in your frontend to optimize performance by preemptively initiating a connection with the Quick Auth Server. ```html ``` -------------------------------- ### Create New Farcaster Mini App Project Source: https://miniapps.farcaster.xyz/llms-full.txt Use the CLI to scaffold a new Farcaster Mini App project. This is recommended for new projects. ```bash npm create @farcaster/mini-app ``` ```bash pnpm create @farcaster/mini-app ``` ```bash yarn create @farcaster/mini-app ``` -------------------------------- ### Cast Embed Location Context Example Source: https://miniapps.farcaster.xyz/docs/sdk/context Example of the location context when a Mini App is launched from a cast embed. ```javascript > sdk.context.location { type: "cast_embed", embed: "https://myapp.example.com", cast: { author: { fid: 3621, username: "alice", displayName: "Alice", pfpUrl: "https://example.com/alice.jpg" }, hash: "0xa2fbef8c8e4d00d8f84ff45f9763b8bae2c5c544", timestamp: 1749160866000, mentions: [], text: "Check out this awesome mini app!", embeds: ["https://myapp.example.com"], channelKey: "farcaster" } } ``` -------------------------------- ### Initialize and Display Mini App Content Source: https://miniapps.farcaster.xyz/llms-full.txt After your app loads, call `sdk.actions.ready()` to hide the splash screen and display your content. Failure to call this will result in an infinite loading screen. ```javascript import { sdk } from '@farcaster/miniapp-sdk' // After your app is fully loaded and ready to display await sdk.actions.ready() ``` -------------------------------- ### Open a Mini App using Embed or Launch URL Source: https://miniapps.farcaster.xyz/llms-full.txt Demonstrates how to open another Mini App using either a direct embed URL or a Farcaster launch URL. Ensure the SDK is imported before use. ```typescript import { sdk } from '@farcaster/miniapp-sdk' // Open a Mini App using an embed URL await sdk.actions.openMiniApp({ url: 'https://www.bountycaster.xyz/bounty/0x983ad3e340fbfef785e0705ff87c0e63c22bebc4' }) // Open a Mini App using a launch URL await sdk.actions.openMiniApp({ url: 'https://farcaster.xyz/miniapps/WoLihpyQDh7w/farville' }) ``` -------------------------------- ### Cast Share Location Context Example Source: https://miniapps.farcaster.xyz/docs/sdk/context Example of the location context when a Mini App is launched via a cast share. ```javascript > sdk.context.location { type: "cast_share", cast: { author: { fid: 12152, username: "pirosb3", displayName: "Daniel - Bountycaster", pfpUrl: "https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/7229dfa5-4873-42d0-9dd0-69f4f3fc4d00/original" }, hash: "0x1177603a7464a372fc358a7eabdeb70880d81612", timestamp: 1749160866000, mentions: [], text: "Sharing this interesting cast with you!", embeds: ["https://frames-v2.vercel.app/"], channelKey: "staging" } } ``` -------------------------------- ### Import and Use viewCast Action Source: https://miniapps.farcaster.xyz/docs/sdk/actions/view-cast Import the SDK and use the viewCast action to open a specific cast. Ensure you have the cast hash available. ```javascript import { sdk } from '@farcaster/miniapp-sdk' await sdk.actions.viewCast({ hash: castHash, }) ``` -------------------------------- ### Notification Location Context Example Source: https://miniapps.farcaster.xyz/llms-full.txt Example of the `location` context when a Mini App is launched from a notification. Includes notification ID, title, and body. ```typescript > sdk.context.location { type: "notification", notification: { notificationId: "f7e9ebaf-92f0-43b9-a410-ad8c24f3333b" title: "Yoinked!", body: "horsefacts captured the flag from you.", } } ``` -------------------------------- ### New Domain Manifest Configuration Source: https://miniapps.farcaster.xyz/llms-full.txt Configure your Mini App's manifest on the new domain. Ensure the `accountAssociation` and `miniapp` details are correct, including the `homeUrl` pointing to the new domain. ```json { "accountAssociation": { "header": "...", "payload": "...", "signature": "..." }, "miniapp": { "version": "1", "name": "Your App Name", "iconUrl": "https://new-domain.com/icon.png", "homeUrl": "https://new-domain.com", "// ... other configuration": "" } } ``` -------------------------------- ### Example Farcaster Manifest JSON Source: https://miniapps.farcaster.xyz/docs/guides/agents-checklist This is a valid Farcaster manifest example, including accountAssociation and frame details. It serves as a reference for expected structure and content. ```json { "accountAssociation": { "header": "eyJmaWQiOjEyMTUyLCJ0eXBlIjoiY3VzdG9keSIsImtleSI6IjB4MEJGNDVGOTY3RTkwZmZENjA2MzVkMUFDMTk1MDYyYTNBOUZjQzYyQiJ9", "payload": "eyJkb21haW4iOiJ3d3cuYm91bnR5Y2FzdGVyLnh5eiJ9", "signature": "MHhmMTUwMWRjZjRhM2U1NWE1ZjViNGQ5M2JlNGIxYjZiOGE0ZjcwYWQ5YTE1OTNmNDk1NzllNTA2YjJkZGZjYTBlMzI4ZmRiNDZmNmVjZmFhZTU4NjYwYzBiZDc4YjgzMzc2MDAzYTkxNzhkZGIyZGIyZmM5ZDYwYjU2YTlmYzdmMDFj" }, "frame": { "version": "1", "name": "Bountycaster", "iconUrl": "https://www.bountycaster.xyz/static/images/bounty/logo.png", "homeUrl": "https://www.bountycaster.xyz", "imageUrl": "https://www.bountycaster.xyz/static/images/bounty/logo.png", "buttonTitle": "Open Bounty", "splashImageUrl": "https://www.bountycaster.xyz/static/images/bounty/logo.png", "splashBackgroundColor": "#FFFFFF" } } ``` -------------------------------- ### Cast Embed Location Context Example Source: https://miniapps.farcaster.xyz/llms-full.txt Example of the `location` context when a Mini App is launched from a cast where it is embedded. Includes details of the cast and the embed URL. ```typescript > sdk.context.location { type: "cast_embed", embed: "https://myapp.example.com", cast: { author: { fid: 3621, username: "alice", displayName: "Alice", pfpUrl: "https://example.com/alice.jpg" }, hash: "0xa2fbef8c8e4d00d8f84ff45f9763b8bae2c5c544", timestamp: 1749160866000, mentions: [], text: "Check out this awesome mini app!", embeds: ["https://myapp.example.com"], channelKey: "farcaster" } } ``` -------------------------------- ### Cast Share Location Context Example Source: https://miniapps.farcaster.xyz/llms-full.txt Example of the `location` context when a Mini App is launched by a user sharing a cast to the app. Provides details of the shared cast. ```typescript > sdk.context.location { type: "cast_share", cast: { author: { fid: 12152, username: "pirosb3", displayName: "Daniel - Bountycaster", pfpUrl: "https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/7229dfa5-4873-42d0-9dd0-69f4f3fc4d00/original" }, hash: "0x1177603a7464a372fc358a7eabdeb70880d81612", timestamp: 1749160866000, mentions: [], text: "Sharing this interesting cast with you!", embeds: ["https://frames-v2.vercel.app/"], channelKey: "staging" } } ``` -------------------------------- ### ready Source: https://miniapps.farcaster.xyz/llms-full.txt Hides the Mini App's splash screen, indicating it is ready for interaction. ```APIDOC ## ready ### Description Hides the Splash Screen. ### Endpoint /docs/sdk/actions/ready ``` -------------------------------- ### Display Mini App Content Source: https://miniapps.farcaster.xyz/docs/getting-started Call `sdk.actions.ready()` after your app is fully loaded to hide the splash screen and display your content. Failure to call this will result in an infinite loading screen. ```javascript import { sdk } from '@farcaster/miniapp-sdk' // After your app is fully loaded and ready to display await sdk.actions.ready() ``` -------------------------------- ### Install Farcaster Mini App Wagmi Connector Source: https://miniapps.farcaster.xyz/docs/guides/wallets Install the necessary Wagmi connector package for Farcaster Mini Apps. This package enables interaction with the user's EVM wallet. ```bash npm install @farcaster/miniapp-wagmi-connector ``` -------------------------------- ### Add a Mini App using SDK Source: https://miniapps.farcaster.xyz/docs/sdk/actions/add-miniapp Use this action to prompt the user to add the Mini App. Ensure your app's domain exactly matches the domain in your manifest file. Tunnel domains are not supported for this action. ```javascript import { sdk } from '@farcaster/miniapp-sdk' await sdk.actions.addMiniApp() ``` -------------------------------- ### Create Empty Manifest File Source: https://miniapps.farcaster.xyz/docs/guides/publishing Use this command to create an empty manifest file in the public directory. ```bash touch public/.well-known/farcaster.json ``` -------------------------------- ### Check Node.js Version Source: https://miniapps.farcaster.xyz/docs/getting-started Verify your installed Node.js version. Ensure it is 22.11.0 or higher, as earlier versions are not supported. ```bash node --version ``` -------------------------------- ### Redirects in Hono Source: https://miniapps.farcaster.xyz/docs/guides/publishing Implement a redirect in Hono for the Farcaster manifest endpoint. This example uses a 307 status code for the redirect. ```typescript import { Hono } from 'hono' const app = new Hono() app.get('/.well-known/farcaster.json', (c) => { return c.redirect('https://api.farcaster.xyz/miniapps/hosted-manifest/1234567890', 307) }) ``` -------------------------------- ### Using getCapabilities() for Haptics Source: https://miniapps.farcaster.xyz/docs/sdk/context Demonstrates checking for specific haptic capabilities using `sdk.getCapabilities()` before attempting to trigger a haptic event. This provides fine-grained detection of supported SDK methods. ```javascript import { sdk } from '@farcaster/miniapp-sdk' // Get list of supported capabilities const capabilities = await sdk.getCapabilities() // Check if specific haptic methods are supported if (capabilities.includes('haptics.impactOccurred')) { // Impact haptic feedback is available await sdk.haptics.impactOccurred('medium') } ``` -------------------------------- ### Initialize Farcaster Mini App SDK Source: https://miniapps.farcaster.xyz/docs/guides/agents-checklist Ensure your Farcaster mini app calls `sdk.actions.ready()` after initialization to properly display the app. This is crucial for preventing issues like an infinite splash screen. ```typescript import { sdk } from '@farcaster/miniapp-sdk' // After app is ready to display await sdk.actions.ready() ``` -------------------------------- ### View a Specific Cast Source: https://miniapps.farcaster.xyz/docs/sdk/actions/view-cast This example demonstrates how to view a specific cast using its hash. The Farcaster client will open to display the cast. ```javascript // View a specific cast await sdk.actions.viewCast({ hash: "0x6a112e2d35e2d2008e25dd29811e8769d1edd9ca", }); ``` -------------------------------- ### getToken Source: https://miniapps.farcaster.xyz/llms-full.txt Gets a signed Quick Auth token. This function is essential for initiating the authentication process and obtaining a token that can be used for subsequent requests. ```APIDOC ## getToken ### Description Gets a signed Quick Auth token. ### Method GET ### Endpoint /quick-auth/token ### Parameters #### Query Parameters - **nonce** (string) - Required - A nonce generated by the client to ensure uniqueness and prevent replay attacks. ### Response #### Success Response (200) - **token** (string) - A signed JWT token that can be used as a session token. #### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" } ``` ``` -------------------------------- ### Notification Haptic Feedback Examples Source: https://miniapps.farcaster.xyz/llms-full.txt Illustrates triggering notification haptic feedback for success, warning, or error states. Use these to indicate task outcomes. ```typescript import { sdk } from '@farcaster/miniapp-sdk' // After successful action await sdk.haptics.notificationOccurred('success') // When showing a warning await sdk.haptics.notificationOccurred('warning') // On error await sdk.haptics.notificationOccurred('error') ``` -------------------------------- ### Example Farcaster JSON Configuration Source: https://miniapps.farcaster.xyz/docs/guides/publishing This snippet shows a complete `farcaster.json` file with various Mini App metadata properties. It includes essential fields like version, name, icon URL, and home URL, along with optional fields for splash images, required chains, and capabilities. ```json { "miniapp": { "version": "1", "name": "Yoink!", "iconUrl": "https://yoink.party/logo.png", "homeUrl": "https://yoink.party/framesV2/", "imageUrl": "https://yoink.party/framesV2/opengraph-image", "buttonTitle": "🚩 Start", "splashImageUrl": "https://yoink.party/logo.png", "splashBackgroundColor": "#f5f0ec", "requiredChains": [ "eip155:8453" ], "requiredCapabilities": [ "actions.signIn", "wallet.getEthereumProvider", "actions.swapToken" ] } } ``` -------------------------------- ### getCapabilities Source: https://miniapps.farcaster.xyz/docs/sdk/detecting-capabilities This SDK method returns a list of supported SDK methods as an array of paths to those SDK methods. ```APIDOC ## getCapabilities ### Description Returns a list of supported SDK methods as an array of paths to those SDK methods. ### Method SDK Method ### Endpoint N/A (SDK Method) ### Parameters None ### Response #### Success Response - **capabilities** (array) - An array of strings, where each string is a path to a supported SDK method. ```