AI Integration Prompt
Copy this prompt into your AI coding assistant (Claude Code, GitHub Copilot, Cursor, Codex, etc.) to help it understand how to integrate x402 payments into your project.
Prompt
@puga-labs/x402-mantle-sdk for gasless API monetization with USDC payments on Mantle blockchain.
KEY INFO:
- Payments use USDC on Mantle (chainId: 5000, USDC: 0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9)
- USDC only - requires EIP-3009 (transferWithAuthorization) which only USDC supports on Mantle
- Users sign authorizations (gasless for them), facilitator executes transfers and pays gas
- Server returns 402 + payment requirements, client SDK handles flow automatically
- Price in USD: priceUsd: 0.01 = 1 cent, converted to USDC atomic units internally
IMPORTS:
- Server Express: import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/express'
- Server Next.js: import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/nextjs'
- Server Web (Hono/CF/Deno): import { mantlePaywall } from '@puga-labs/x402-mantle-sdk/server/web'
- Client React: import { useMantleX402, useEthersWallet } from '@puga-labs/x402-mantle-sdk/react'
- Client Vanilla: import { createMantleClient } from '@puga-labs/x402-mantle-sdk/client'
SERVER PATTERN (Self-Hosted - Recommended):
const pay = mantlePaywall({
priceUsd: 0.01,
payTo: '0xYourWalletAddress',
facilitatorUrl: 'https://your-facilitator.com',
facilitatorSecret: process.env.FACILITATOR_SECRET! // Required for self-hosted
});
// Express: app.post('/api/endpoint', pay, handler)
// Next.js: export const POST = pay(async (req) => NextResponse.json({ result }))
// Web: app.post('/path', pay(async (req) => new Response(...)))
SERVER PATTERN (Hosted):
const pay = mantlePaywall({
priceUsd: 0.01,
payTo: '0xYourWalletAddress',
projectKey: 'pk_xxx' // Get from dashboard - no facilitatorUrl needed!
});
CLIENT PATTERN (React):
// facilitatorUrl auto-detected from backend 402 response - no config needed!
const { postWithPayment } = useMantleX402();
const { response, txHash } = await postWithPayment('/api/endpoint', { data });
CLIENT PATTERN (Vanilla):
// facilitatorUrl auto-detected from backend 402 response
const client = createMantleClient({
resourceUrl: 'https://your-api.com',
getProvider: () => window.ethereum,
getAccount: () => userAddress
});
const { response, txHash } = await client.postWithPayment('/api/endpoint', { data });
CONFIG OPTIONS:
- facilitatorUrl: string - for self-hosted (your facilitator URL)
- facilitatorSecret: string - for self-hosted (required with facilitatorUrl)
- projectKey: string - for hosted facilitator (get from dashboard)
- onPaymentSettled: (entry) => void - callback with { from, to, valueAtomic, txHash, route }
- telemetry: { debug: true } - for analytics (auto-uses projectKey)
URLS:
- Dashboard & Project Keys: https://x402mantlesdk.xyz/dashboard
- Docs: https://x402mantlesdk.xyz/docs
Usage Tips
For Cursor / Windsurf
Add to .cursorrules or rules file in project root.
For Claude Code
Add to CLAUDE.md in project root, or paste at start of conversation.
For GitHub Copilot
Add to .github/copilot-instructions.md or reference in comments.
For Codex / ChatGPT
Paste at the beginning of your conversation or in system prompt.
Keep Updated
This prompt is for SDK version 0.4.x. Check this page for updates when upgrading the SDK.