Mini apps enable third-party developers to create native-like applications within World App.
This template demonstrates how to integrate ATXP (Autonomous Transaction Execution Protocol) into a World Mini App, enabling AI-powered payments and MCP (Model Context Protocol) server interactions.
- 🤖 ATXP Integration - AI-powered payment processing for MCP servers
- 🖼️ Image Generation - Example of paying for AI services with USDC on World Chain
- 💳 MiniKit Payments - Seamless in-app USDC transactions
- 🔧 MCP Protocol - Connect to AI services with automatic payment handling
- Node.js 18+ and pnpm
- World App installed on your device
-
Clone and set up environment:
cp .env.example .env.local # Follow the instructions in the .env.local file -
Install dependencies:
pnpm install
-
Set up authentication:
npx auth secret # Updates AUTH_SECRET in .env.local -
Start development server:
pnpm run dev
-
Set up tunnel for testing:
ngrok http 3000
-
Configure your ngrok URL:
- Update
AUTH_URLin.env.localwith your ngrok URL - The
next.config.tsautomatically reads fromAUTH_URLfor domain configuration - Register your app at developer.worldcoin.org
- Update
- Login to the app using World App
- Navigate to Image Generation to test ATXP payments
- Generate an image - this will trigger a USDC payment on World Chain through ATXP
- Monitor the console for detailed payment and MCP interaction logs
The ATXP integration is primarily implemented in src/contexts/atxpContext.tsx, which provides:
// Automatic account initialization when user logs in
const atxpAccount = await createMiniKitWorldchainAccount({
walletAddress,
miniKit: MiniKit
});// Connect to MCP servers with automatic payment handling
const imageClient = await atxpClient({
account: atxpAccount,
mcpServer: "https://image.mcp.atxp.ai/",
onPayment: async ({ payment }) => {
console.log("Payment processed:", payment);
}
});- User Authentication - World App wallet authentication via MiniKit
- ATXP Account Setup - Creates Worldchain account with MiniKit provider
- MCP Client Creation - Connects to AI services with payment capabilities
- Service Calls - AI requests automatically trigger USDC payments when needed
- Payment Confirmation - Real-time payment status and transaction monitoring
src/contexts/atxpContext.tsx- Main ATXP integration logicsrc/providers/index.tsx- Buffer polyfills and global setup
// 1. Generate image with automatic payment
const result = await generateImage({
prompt: "A sunset over mountains",
messageId: "msg_123"
});
// 2. ATXP handles the payment flow:
// - Detects MCP server requires payment
// - Prompts user for USDC payment via MiniKit
// - Executes payment on World Chain
// - Forwards request to AI service
// - Returns generated image URL
// 3. Wait for async processing
const imageUrl = await waitForImage({ taskId: result.taskId });This starter kit uses Minikit's wallet auth to authenticate users, and next-auth to manage sessions.
This starter kit uses Mini Apps UI Kit to style the app. We recommend using the UI kit to make sure you are compliant with World App's design system.
This example uses locally linked ATXP packages:
"@atxp/client": "^0.7.0",
"@atxp/common": "^0.7.0",
"@atxp/worldchain": "^0.7.0"Key environment variables in .env.local:
AUTH_SECRET- NextAuth.js authentication secretAUTH_URL- Your ngrok URL for development (automatically used by next.config.ts)NEXT_PUBLIC_APP_ID- Your World App ID from developer portal
The app includes browser polyfills for Node.js Buffer in src/providers/index.tsx to support:
- ATXP cryptographic operations
- MCP protocol message encoding/decoding
- Base64url encoding for OAuth flows
-
"signMessage command is unavailable"
- Ensure MiniKit is properly initialized in the React context
- Verify you're passing the MiniKit instance to
createMiniKitWorldchainAccount
-
"Buffer is not defined"
- Clear
node_modulesand reinstall:rm -rf node_modules && pnpm install - Restart dev server after installing new dependencies
- Clear
-
Authentication failures
- Check that
AUTH_SECRETmatches between.env.localand your auth configuration - Verify your ngrok URL is registered in the World developer portal
- Check that
Eruda provides in-app console debugging. Disable in production:
// src/providers/index.tsx
const ErudaProvider = dynamic(
() => import('@/providers/Eruda').then((c) => c.ErudaProvider),
{ ssr: false }
);This template was made with help from the amazing supercorp-ai team.
