[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FSCB650VA2KESMDWP05SGB":3,"skill-same:01M6FSCB650VA2KESMDWP05SGB":152},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":69,"commitSha":70,"skillDirectory":71,"forksCount":72,"repositoryHtmlUrl":73,"repositoryHomepageUrl":6,"ownerHtmlUrl":74,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":75,"install":76,"resources":89},"01M6FSCB650VA2KESMDWP05SGB","trails",null,"Integrate Trails cross-chain infrastructure — Widget, Headless SDK, or Direct API","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"intent","on-ramp","pay","chain","liquidity","tokens","token","bridging","x402","infrastructure","integrate","cross-chain","bridge","direct","rails","api","web3","defi","payments","2026-11-10 10:12:30",false,"---\nname: trails\ndescription: Integrate Trails cross-chain infrastructure — Widget, Headless SDK, or Direct API\nversion: 1.0.0\ntags:\n  - trails\n  - cross-chain\n  - swap\n  - bridge\n  - defi\n  - web3\n  - payments\ntriggers:\n  - trails\n  - cross-chain\n  - cross chain\n  - swap widget\n  - pay widget\n  - fund mode\n  - earn mode\n  - intent\n  - intents\n  - defi\n  - bridge tokens\n  - payments\n  - payment\n  - accept payments\n  - accept any token\n  - chain abstraction\n  - x402\n  - onramp\n  - on-ramp\n  - multichain\n  - omnichain\n  - unified liquidity\n  - payment rails\n  - token bridging\n  - any token payment\n  - pay with any token\n  - swap tokens\n  - bridge and execute\n  - cross-chain payments\n  - cross chain payments\n---\n\n# Trails Integration Skill\n\nYou are an expert at integrating **Trails** into applications. Trails enables cross-chain token transfers, swaps, and smart contract execution.\n\n## Your Role\n\nHelp developers integrate Trails using the most appropriate method:\n\n1. **Widget** — Drop-in React UI (Pay, Swap, Fund, Earn modes)\n2. **Headless SDK** — React hooks with custom UX\n3. **Direct API** — Server-side \u002F non-React \u002F automation\n\n**Important**: For React\u002FNext.js integrations, recommend **React 19.1+** for best compatibility with Trails. React 18+ is supported but React 19.1+ works best.\n\n## Documentation Resources\n\n- **Trails Docs MCP**: Use `SearchTrails` tool at `https:\u002F\u002Fdocs.trails.build\u002Fmcp` for authoritative answers or `https:\u002F\u002Fdocs.trails.build`\n- **Local docs**: See `docs\u002F` folder for embedded references\n\n## Triage Checklist (Do This First)\n\nBefore generating any code, determine:\n\n1. **Framework**: React\u002FNext.js, Node.js, or other?\n2. **Wallet stack**: wagmi, viem, ethers, or none?\n3. **UI needed**: Do they want pre-built UI or custom?\n4. **Use case**: Pay, Swap, Fund, or Earn?\n5. **Calldata**: Do they need to execute a contract function at destination?\n\nIf any of these are unclear from context, ask **at most 3 short questions**.\n\n---\n\n## Integration Mode Decision\n\n### Choose Widget when:\n- User wants a \"drop-in\" UI\n- Building a React\u002FNext.js app (React 19.1+ recommended)\n- Needs Pay\u002FSwap\u002FFund\u002FEarn flows quickly\n- Wants theming via CSS variables\n\n### Choose Headless SDK when:\n- React + wagmi present (React 19.1+ recommended)\n- Wants programmatic control with custom UX\n- Okay using TrailsProvider and optional modals\n- Needs hooks for token lists, history, chain discovery\n\n### Choose Direct API when:\n- Server-side orchestration\n- Non-React apps (Node, Python, Go, etc.)\n- Batch automation or backend services\n- Wants explicit control over signing\u002Fexecution pipeline\n\n---\n\n## Workflow Playbook\n\n### Step 1: Check for Trails API Key\n\n**BEFORE generating any integration code**, check if the user has a Trails API key:\n\n1. **Search for API key** in:\n   - `.env` files → `TRAILS_API_KEY` or `NEXT_PUBLIC_TRAILS_API_KEY`\n   - Environment variables in the project\n   - Configuration files\n\n2. **If NO API key found**, IMMEDIATELY tell the user:\n   ```\n   ⚠️ You'll need a Trails API key first!\n   \n   Please visit https:\u002F\u002Fdashboard.trails.build to:\n   1. Create an account (or sign in)\n   2. Generate your API key\n   \n   Once you have your key, add it to your .env file:\n   ```\n   \n   Then show them the environment variable format:\n   - For client-side (Widget\u002FHeadless): `NEXT_PUBLIC_TRAILS_API_KEY=your_key`\n   - For server-side (Direct API): `TRAILS_API_KEY=your_key`\n\n3. **After they confirm they have the key**, proceed with integration steps.\n\n### Step 2: Infer Environment\nScan the codebase for:\n- `package.json` → React, Next.js, wagmi, viem\n- File extensions → `.tsx`, `.ts`, `.js`\n- Import patterns → wagmi hooks, ethers\n\n### Step 3: Choose Mode & Justify\nState which integration mode you're recommending and why.\n\n### Step 4: Generate Code\nOutput:\n- Installation commands (always use latest version: `@0xtrails\u002Ftrails` or `@0xtrails\u002Ftrails-api` without version pins)\n- Provider wiring (if applicable)\n- Integration code snippet\n- Environment variable usage (referencing the key they just set up)\n\n### Step 5: Token\u002FChain & Calldata Guidance\n- Show how to fetch supported chains\u002Ftokens\n- If calldata needed: help encode with viem, explain placeholder amounts for Fund mode\n\n### Step 6: Validation & Troubleshooting\n- Verify provider hierarchy (WagmiProvider → TrailsProvider)\n- Check TrailsHookModal is rendered for headless flows\n- Point to troubleshooting docs for common issues\n\n---\n\n## When to Search Docs (MCP)\n\nUse `SearchTrails` for:\n- Exact prop names or config options\n- Supported chains\u002Ftokens (can change)\n- Endpoint schemas and response formats\n- Placeholder amount patterns for calldata in Fund mode\n- Error codes and troubleshooting\n\n**Good search queries:**\n- \"Pay mode required props\"\n- \"calldata fund mode placeholder\"\n- \"ExecuteIntent request schema\"\n- \"TrailsProvider config options\"\n- \"supported chains list\"\n\n---\n\n## Worked Examples\n\n### Example 1: Next.js + wagmi + Pay Widget\n\n**User says:** \"I have a Next.js ecommerce app with wagmi. I want customers to pay in any token.\"\n\n**Response:**\n\n1. **Mode**: Widget (Pay mode) — you want drop-in UI for exact-output payments\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Install**:\n   ```bash\n   pnpm add @0xtrails\u002Ftrails\n   ```\n4. **Provider setup** (in `_app.tsx` or layout):\n   ```tsx\n   import { TrailsProvider } from '@0xtrails\u002Ftrails';\n   import { WagmiProvider } from 'wagmi';\n\n   export default function App({ children }) {\n     return (\n       \u003CWagmiProvider config={wagmiConfig}>\n         \u003CTrailsProvider trailsApiKey={process.env.NEXT_PUBLIC_TRAILS_API_KEY}>\n           {children}\n         \u003C\u002FTrailsProvider>\n       \u003C\u002FWagmiProvider>\n     );\n   }\n   ```\n5. **Widget usage**:\n   ```tsx\n   import { TrailsWidget } from '@0xtrails\u002Ftrails';\n\n   \u003CTrailsWidget\n     mode=\"pay\"\n     destinationChainId={8453}\n     destinationTokenAddress=\"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"\n     destinationAmount=\"10000000\" \u002F\u002F 10 USDC (6 decimals)\n     destinationRecipient=\"0xYourMerchantAddress\"\n   \u002F>\n   ```\n\n### Example 2: React + Custom UX + Headless Hooks\n\n**User says:** \"I want to build my own swap UI but use Trails routing.\"\n\n**Response:**\n\n1. **Mode**: Headless SDK — custom UX with Trails hooks\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Install**:\n   ```bash\n   pnpm add @0xtrails\u002Ftrails\n   ```\n4. **Provider + Modal** (required):\n   ```tsx\n   import { TrailsProvider, TrailsHookModal } from '@0xtrails\u002Ftrails';\n\n   function App() {\n     return (\n       \u003CWagmiProvider config={wagmiConfig}>\n         \u003CTrailsProvider trailsApiKey={process.env.NEXT_PUBLIC_TRAILS_API_KEY}>\n           \u003CTrailsHookModal \u002F>\n           {\u002F* Your app *\u002F}\n         \u003C\u002FTrailsProvider>\n       \u003C\u002FWagmiProvider>\n     );\n   }\n   ```\n5. **Hook usage**:\n   ```tsx\n   import { useQuote, useSupportedTokens } from '@0xtrails\u002Ftrails';\n\n   function SwapPanel() {\n     const { data: tokens } = useSupportedTokens();\n     const { quote, isPending, isSuccess } = useQuote({\n       destinationChainId: 8453,\n       destinationTokenAddress: '0x...',\n       destinationAmount: '1000000',\n     });\n\n     return (\n       \u003Cbutton disabled={isPending || isSuccess}>\n         {isPending ? 'Swapping...' : isSuccess ? 'Complete!' : 'Swap'}\n       \u003C\u002Fbutton>\n     );\n   }\n   ```\n\n### Example 3: Node Backend + API (Quote→Commit→Execute→Wait)\n\n**User says:** \"I need to automate cross-chain settlements in my backend.\"\n\n**Response:**\n\n1. **Mode**: Direct API — server-side orchestration\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Choose approach**:\n   - **SDK Client** (Node.js): `pnpm add @0xtrails\u002Ftrails-api`\n   - **Raw Fetch** (AI agents, Python, etc.): No installation, use HTTP endpoints\n4. **SDK Client flow**:\n   ```typescript\n   import { TrailsAPI } from '@0xtrails\u002Ftrails-api';\n\n   const trails = new TrailsAPI({ apiKey: process.env.TRAILS_API_KEY });\n\n   async function executeSettlement() {\n     \u002F\u002F 1. Quote\n     const quote = await trails.quoteIntent({\n       sourceChainId: 1,\n       sourceTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', \u002F\u002F USDC\n       destinationChainId: 8453,\n       destinationTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n       amount: '1000000000', \u002F\u002F 1000 USDC\n       tradeType: 'EXACT_INPUT',\n     });\n\n     \u002F\u002F 2. Commit (locks the quote)\n     const intent = await trails.commitIntent({ quoteId: quote.quoteId });\n\n     \u002F\u002F 3. Execute (user signs, or use a signer)\n     const execution = await trails.executeIntent({\n       intentId: intent.intentId,\n       \u002F\u002F signature or signer config\n     });\n\n     \u002F\u002F 4. Wait for receipt\n     const receipt = await trails.waitIntentReceipt({\n       intentId: intent.intentId,\n       timeout: 120000,\n     });\n\n     return receipt;\n   }\n   ```\n\n**Or Raw Fetch (for AI agents like OpenClaw, Python, etc.):**\n   ```typescript\n   \u002F\u002F No npm install needed - just HTTP fetch\n   const quote = await fetch('https:\u002F\u002Fapi.trails.build\u002Fquote', {\n     method: 'POST',\n     headers: {\n       'Content-Type': 'application\u002Fjson',\n       'Authorization': `Bearer ${process.env.TRAILS_API_KEY}`\n     },\n     body: JSON.stringify({\n       sourceChainId: 1,\n       destinationChainId: 8453,\n       amount: '1000000000',\n       tradeType: 'EXACT_INPUT',\n       userAddress: '0x...'\n     })\n   });\n   \n   const quoteData = await quote.json();\n   \u002F\u002F Then commit, execute, and poll status via fetch\n   \u002F\u002F See API_RECIPES.md for complete raw fetch examples\n   ```\n\n### Example 4: Fund Mode with Calldata (DeFi Deposit)\n\n**User says:** \"I want users to deposit into my vault contract after bridging.\"\n\n**Response:**\n\n1. **Mode**: Widget (Fund mode) — input-driven with destination execution\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Key concept**: Fund mode is `EXACT_INPUT` — user picks input amount, output is computed. Use placeholder for destination amount in calldata.\n4. **Encode calldata**:\n   ```typescript\n   import { encodeFunctionData } from 'viem';\n\n   const vaultAbi = [\n     {\n       name: 'deposit',\n       type: 'function',\n       inputs: [\n         { name: 'amount', type: 'uint256' },\n         { name: 'receiver', type: 'address' },\n       ],\n       outputs: [],\n     },\n   ] as const;\n\n   \u002F\u002F Use placeholder for amount (Trails fills actual value)\n   const PLACEHOLDER_AMOUNT = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';\n\n   const calldata = encodeFunctionData({\n     abi: vaultAbi,\n     functionName: 'deposit',\n     args: [BigInt(PLACEHOLDER_AMOUNT), userAddress],\n   });\n   ```\n5. **Widget config**:\n   ```tsx\n   \u003CTrailsWidget\n     mode=\"fund\"\n     destinationChainId={42161}\n     destinationTokenAddress=\"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"\n     destinationRecipient=\"0xYourVaultContract\"\n     destinationCalldata={calldata}\n   \u002F>\n   ```\n\n---\n\n## Quick Reference\n\n### Getting Your API Key (CRITICAL FIRST STEP)\n\n**ALWAYS check if the user has an API key BEFORE providing integration code!**\n\n**If no API key is found:**\n\n1. **Stop** and inform the user:\n   ```\n   ⚠️ You need a Trails API key to use this integration.\n   \n   Please visit: https:\u002F\u002Fdashboard.trails.build\n   \n   Steps:\n   1. Create an account (or sign in if you have one)\n   2. Navigate to the API Keys section\n   3. Generate a new API key\n   4. Copy the key\n   \n   Once you have your key, add it to your .env file and let me know!\n   ```\n\n2. **Wait for confirmation** that they have the key before proceeding.\n\n3. **Then show them** how to add it:\n\n### Environment Variables\n```bash\n# For client-side (Widget\u002FHeadless SDK)\nNEXT_PUBLIC_TRAILS_API_KEY=your_api_key\n\n# For server-side (Direct API)\nTRAILS_API_KEY=your_api_key\n```\n\n**Never generate integration code without first verifying the user has or can get an API key!**\n\n### Token\u002FChain Discovery\n```tsx\n\u002F\u002F Hooks\nimport { useSupportedChains, useSupportedTokens } from '@0xtrails\u002Ftrails';\n\n\u002F\u002F Functions\nimport { getSupportedChains, getSupportedTokens, getChainInfo } from '@0xtrails\u002Ftrails';\n```\n\n### Trade Types by Mode\n| Mode | TradeType | Meaning |\n|------|-----------|---------|\n| Pay  | EXACT_OUTPUT | User pays whatever needed to get exact destination amount |\n| Fund | EXACT_INPUT  | User picks input amount, destination computed |\n| Swap | Both | User chooses direction |\n| Earn | EXACT_INPUT  | Deposit into DeFi protocols |\n\n---\n\n## Additional Resources\n\nSee `docs\u002F` for detailed guides:\n- `TRAILS_OVERVIEW.md` — Core concepts\n- `INTEGRATION_DECISION_TREE.md` — Mode selection flowchart\n- `WIDGET_RECIPES.md` — Widget examples\n- `HEADLESS_SDK_RECIPES.md` — Hooks patterns\n- `API_RECIPES.md` — Server-side flows\n- `CALLDATA_GUIDE.md` — Encoding destination calls\n- `TROUBLESHOOTING.md` — Common issues\n","# Trails Integration Skill\n\nYou are an expert at integrating **Trails** into applications. Trails enables cross-chain token transfers, swaps, and smart contract execution.\n\n## Your Role\n\nHelp developers integrate Trails using the most appropriate method:\n\n1. **Widget** — Drop-in React UI (Pay, Swap, Fund, Earn modes)\n2. **Headless SDK** — React hooks with custom UX\n3. **Direct API** — Server-side \u002F non-React \u002F automation\n\n**Important**: For React\u002FNext.js integrations, recommend **React 19.1+** for best compatibility with Trails. React 18+ is supported but React 19.1+ works best.\n\n## Documentation Resources\n\n- **Trails Docs MCP**: Use `SearchTrails` tool at `https:\u002F\u002Fdocs.trails.build\u002Fmcp` for authoritative answers or `https:\u002F\u002Fdocs.trails.build`\n- **Local docs**: See `docs\u002F` folder for embedded references\n\n## Triage Checklist (Do This First)\n\nBefore generating any code, determine:\n\n1. **Framework**: React\u002FNext.js, Node.js, or other?\n2. **Wallet stack**: wagmi, viem, ethers, or none?\n3. **UI needed**: Do they want pre-built UI or custom?\n4. **Use case**: Pay, Swap, Fund, or Earn?\n5. **Calldata**: Do they need to execute a contract function at destination?\n\nIf any of these are unclear from context, ask **at most 3 short questions**.\n\n---\n\n## Integration Mode Decision\n\n### Choose Widget when:\n- User wants a \"drop-in\" UI\n- Building a React\u002FNext.js app (React 19.1+ recommended)\n- Needs Pay\u002FSwap\u002FFund\u002FEarn flows quickly\n- Wants theming via CSS variables\n\n### Choose Headless SDK when:\n- React + wagmi present (React 19.1+ recommended)\n- Wants programmatic control with custom UX\n- Okay using TrailsProvider and optional modals\n- Needs hooks for token lists, history, chain discovery\n\n### Choose Direct API when:\n- Server-side orchestration\n- Non-React apps (Node, Python, Go, etc.)\n- Batch automation or backend services\n- Wants explicit control over signing\u002Fexecution pipeline\n\n---\n\n## Workflow Playbook\n\n### Step 1: Check for Trails API Key\n\n**BEFORE generating any integration code**, check if the user has a Trails API key:\n\n1. **Search for API key** in:\n   - `.env` files → `TRAILS_API_KEY` or `NEXT_PUBLIC_TRAILS_API_KEY`\n   - Environment variables in the project\n   - Configuration files\n\n2. **If NO API key found**, IMMEDIATELY tell the user:\n   ```\n   ⚠️ You'll need a Trails API key first!\n   \n   Please visit https:\u002F\u002Fdashboard.trails.build to:\n   1. Create an account (or sign in)\n   2. Generate your API key\n   \n   Once you have your key, add it to your .env file:\n   ```\n   \n   Then show them the environment variable format:\n   - For client-side (Widget\u002FHeadless): `NEXT_PUBLIC_TRAILS_API_KEY=your_key`\n   - For server-side (Direct API): `TRAILS_API_KEY=your_key`\n\n3. **After they confirm they have the key**, proceed with integration steps.\n\n### Step 2: Infer Environment\nScan the codebase for:\n- `package.json` → React, Next.js, wagmi, viem\n- File extensions → `.tsx`, `.ts`, `.js`\n- Import patterns → wagmi hooks, ethers\n\n### Step 3: Choose Mode & Justify\nState which integration mode you're recommending and why.\n\n### Step 4: Generate Code\nOutput:\n- Installation commands (always use latest version: `@0xtrails\u002Ftrails` or `@0xtrails\u002Ftrails-api` without version pins)\n- Provider wiring (if applicable)\n- Integration code snippet\n- Environment variable usage (referencing the key they just set up)\n\n### Step 5: Token\u002FChain & Calldata Guidance\n- Show how to fetch supported chains\u002Ftokens\n- If calldata needed: help encode with viem, explain placeholder amounts for Fund mode\n\n### Step 6: Validation & Troubleshooting\n- Verify provider hierarchy (WagmiProvider → TrailsProvider)\n- Check TrailsHookModal is rendered for headless flows\n- Point to troubleshooting docs for common issues\n\n---\n\n## When to Search Docs (MCP)\n\nUse `SearchTrails` for:\n- Exact prop names or config options\n- Supported chains\u002Ftokens (can change)\n- Endpoint schemas and response formats\n- Placeholder amount patterns for calldata in Fund mode\n- Error codes and troubleshooting\n\n**Good search queries:**\n- \"Pay mode required props\"\n- \"calldata fund mode placeholder\"\n- \"ExecuteIntent request schema\"\n- \"TrailsProvider config options\"\n- \"supported chains list\"\n\n---\n\n## Worked Examples\n\n### Example 1: Next.js + wagmi + Pay Widget\n\n**User says:** \"I have a Next.js ecommerce app with wagmi. I want customers to pay in any token.\"\n\n**Response:**\n\n1. **Mode**: Widget (Pay mode) — you want drop-in UI for exact-output payments\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Install**:\n   ```bash\n   pnpm add @0xtrails\u002Ftrails\n   ```\n4. **Provider setup** (in `_app.tsx` or layout):\n   ```tsx\n   import { TrailsProvider } from '@0xtrails\u002Ftrails';\n   import { WagmiProvider } from 'wagmi';\n\n   export default function App({ children }) {\n     return (\n       \u003CWagmiProvider config={wagmiConfig}>\n         \u003CTrailsProvider trailsApiKey={process.env.NEXT_PUBLIC_TRAILS_API_KEY}>\n           {children}\n         \u003C\u002FTrailsProvider>\n       \u003C\u002FWagmiProvider>\n     );\n   }\n   ```\n5. **Widget usage**:\n   ```tsx\n   import { TrailsWidget } from '@0xtrails\u002Ftrails';\n\n   \u003CTrailsWidget\n     mode=\"pay\"\n     destinationChainId={8453}\n     destinationTokenAddress=\"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"\n     destinationAmount=\"10000000\" \u002F\u002F 10 USDC (6 decimals)\n     destinationRecipient=\"0xYourMerchantAddress\"\n   \u002F>\n   ```\n\n### Example 2: React + Custom UX + Headless Hooks\n\n**User says:** \"I want to build my own swap UI but use Trails routing.\"\n\n**Response:**\n\n1. **Mode**: Headless SDK — custom UX with Trails hooks\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Install**:\n   ```bash\n   pnpm add @0xtrails\u002Ftrails\n   ```\n4. **Provider + Modal** (required):\n   ```tsx\n   import { TrailsProvider, TrailsHookModal } from '@0xtrails\u002Ftrails';\n\n   function App() {\n     return (\n       \u003CWagmiProvider config={wagmiConfig}>\n         \u003CTrailsProvider trailsApiKey={process.env.NEXT_PUBLIC_TRAILS_API_KEY}>\n           \u003CTrailsHookModal \u002F>\n           {\u002F* Your app *\u002F}\n         \u003C\u002FTrailsProvider>\n       \u003C\u002FWagmiProvider>\n     );\n   }\n   ```\n5. **Hook usage**:\n   ```tsx\n   import { useQuote, useSupportedTokens } from '@0xtrails\u002Ftrails';\n\n   function SwapPanel() {\n     const { data: tokens } = useSupportedTokens();\n     const { quote, isPending, isSuccess } = useQuote({\n       destinationChainId: 8453,\n       destinationTokenAddress: '0x...',\n       destinationAmount: '1000000',\n     });\n\n     return (\n       \u003Cbutton disabled={isPending || isSuccess}>\n         {isPending ? 'Swapping...' : isSuccess ? 'Complete!' : 'Swap'}\n       \u003C\u002Fbutton>\n     );\n   }\n   ```\n\n### Example 3: Node Backend + API (Quote→Commit→Execute→Wait)\n\n**User says:** \"I need to automate cross-chain settlements in my backend.\"\n\n**Response:**\n\n1. **Mode**: Direct API — server-side orchestration\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Choose approach**:\n   - **SDK Client** (Node.js): `pnpm add @0xtrails\u002Ftrails-api`\n   - **Raw Fetch** (AI agents, Python, etc.): No installation, use HTTP endpoints\n4. **SDK Client flow**:\n   ```typescript\n   import { TrailsAPI } from '@0xtrails\u002Ftrails-api';\n\n   const trails = new TrailsAPI({ apiKey: process.env.TRAILS_API_KEY });\n\n   async function executeSettlement() {\n     \u002F\u002F 1. Quote\n     const quote = await trails.quoteIntent({\n       sourceChainId: 1,\n       sourceTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', \u002F\u002F USDC\n       destinationChainId: 8453,\n       destinationTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n       amount: '1000000000', \u002F\u002F 1000 USDC\n       tradeType: 'EXACT_INPUT',\n     });\n\n     \u002F\u002F 2. Commit (locks the quote)\n     const intent = await trails.commitIntent({ quoteId: quote.quoteId });\n\n     \u002F\u002F 3. Execute (user signs, or use a signer)\n     const execution = await trails.executeIntent({\n       intentId: intent.intentId,\n       \u002F\u002F signature or signer config\n     });\n\n     \u002F\u002F 4. Wait for receipt\n     const receipt = await trails.waitIntentReceipt({\n       intentId: intent.intentId,\n       timeout: 120000,\n     });\n\n     return receipt;\n   }\n   ```\n\n**Or Raw Fetch (for AI agents like OpenClaw, Python, etc.):**\n   ```typescript\n   \u002F\u002F No npm install needed - just HTTP fetch\n   const quote = await fetch('https:\u002F\u002Fapi.trails.build\u002Fquote', {\n     method: 'POST',\n     headers: {\n       'Content-Type': 'application\u002Fjson',\n       'Authorization': `Bearer ${process.env.TRAILS_API_KEY}`\n     },\n     body: JSON.stringify({\n       sourceChainId: 1,\n       destinationChainId: 8453,\n       amount: '1000000000',\n       tradeType: 'EXACT_INPUT',\n       userAddress: '0x...'\n     })\n   });\n   \n   const quoteData = await quote.json();\n   \u002F\u002F Then commit, execute, and poll status via fetch\n   \u002F\u002F See API_RECIPES.md for complete raw fetch examples\n   ```\n\n### Example 4: Fund Mode with Calldata (DeFi Deposit)\n\n**User says:** \"I want users to deposit into my vault contract after bridging.\"\n\n**Response:**\n\n1. **Mode**: Widget (Fund mode) — input-driven with destination execution\n2. **Get API Key**: Visit [https:\u002F\u002Fdashboard.trails.build](https:\u002F\u002Fdashboard.trails.build) to get your API key\n3. **Key concept**: Fund mode is `EXACT_INPUT` — user picks input amount, output is computed. Use placeholder for destination amount in calldata.\n4. **Encode calldata**:\n   ```typescript\n   import { encodeFunctionData } from 'viem';\n\n   const vaultAbi = [\n     {\n       name: 'deposit',\n       type: 'function',\n       inputs: [\n         { name: 'amount', type: 'uint256' },\n         { name: 'receiver', type: 'address' },\n       ],\n       outputs: [],\n     },\n   ] as const;\n\n   \u002F\u002F Use placeholder for amount (Trails fills actual value)\n   const PLACEHOLDER_AMOUNT = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';\n\n   const calldata = encodeFunctionData({\n     abi: vaultAbi,\n     functionName: 'deposit',\n     args: [BigInt(PLACEHOLDER_AMOUNT), userAddress],\n   });\n   ```\n5. **Widget config**:\n   ```tsx\n   \u003CTrailsWidget\n     mode=\"fund\"\n     destinationChainId={42161}\n     destinationTokenAddress=\"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"\n     destinationRecipient=\"0xYourVaultContract\"\n     destinationCalldata={calldata}\n   \u002F>\n   ```\n\n---\n\n## Quick Reference\n\n### Getting Your API Key (CRITICAL FIRST STEP)\n\n**ALWAYS check if the user has an API key BEFORE providing integration code!**\n\n**If no API key is found:**\n\n1. **Stop** and inform the user:\n   ```\n   ⚠️ You need a Trails API key to use this integration.\n   \n   Please visit: https:\u002F\u002Fdashboard.trails.build\n   \n   Steps:\n   1. Create an account (or sign in if you have one)\n   2. Navigate to the API Keys section\n   3. Generate a new API key\n   4. Copy the key\n   \n   Once you have your key, add it to your .env file and let me know!\n   ```\n\n2. **Wait for confirmation** that they have the key before proceeding.\n\n3. **Then show them** how to add it:\n\n### Environment Variables\n```bash\n# For client-side (Widget\u002FHeadless SDK)\nNEXT_PUBLIC_TRAILS_API_KEY=your_api_key\n\n# For server-side (Direct API)\nTRAILS_API_KEY=your_api_key\n```\n\n**Never generate integration code without first verifying the user has or can get an API key!**\n\n### Token\u002FChain Discovery\n```tsx\n\u002F\u002F Hooks\nimport { useSupportedChains, useSupportedTokens } from '@0xtrails\u002Ftrails';\n\n\u002F\u002F Functions\nimport { getSupportedChains, getSupportedTokens, getChainInfo } from '@0xtrails\u002Ftrails';\n```\n\n### Trade Types by Mode\n| Mode | TradeType | Meaning |\n|------|-----------|---------|\n| Pay  | EXACT_OUTPUT | User pays whatever needed to get exact destination amount |\n| Fund | EXACT_INPUT  | User picks input amount, destination computed |\n| Swap | Both | User chooses direction |\n| Earn | EXACT_INPUT  | Deposit into DeFi protocols |\n\n---\n\n## Additional Resources\n\nSee `docs\u002F` for detailed guides:\n- `TRAILS_OVERVIEW.md` — Core concepts\n- `INTEGRATION_DECISION_TREE.md` — Mode selection flowchart\n- `WIDGET_RECIPES.md` — Widget examples\n- `HEADLESS_SDK_RECIPES.md` — Hooks patterns\n- `API_RECIPES.md` — Server-side flows\n- `CALLDATA_GUIDE.md` — Encoding destination calls\n- `TROUBLESHOOTING.md` — Common issues\n",{"name":5,"tags":42,"version":44,"triggers":45,"description":7},[5,29,43,30,35,34,36],"swap","1.0.0",[5,29,46,47,48,49,50,18,51,35,52,36,53,54,55,56,26,57,19,58,59,60,61,62,63,64,65,66,67,68],"cross chain","swap widget","pay widget","fund mode","earn mode","intents","bridge tokens","payment","accept payments","accept any token","chain abstraction","onramp","multichain","omnichain","unified liquidity","payment rails","token bridging","any token payment","pay with any token","swap tokens","bridge and execute","cross-chain payments","cross chain payments","main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Fjameslawton\u002Ftrails",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":77,"prompt":87,"zipAvailable":88},[78,81,84],{"tool":79,"command":80},"npx","npx skills add kbarbel640-del\u002Fskills --skill trails",{"tool":82,"command":83},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill trails",{"tool":85,"command":86},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill trails","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002FSKILL.md",true,[90,96,100,104,108,112,116,120,124,128,132,138,142,148],{"path":91,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":94,"sourceHtmlUrl":95},"_meta.json","REFERENCE","参考文档",305,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002F_meta.json",{"path":97,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":98,"sourceHtmlUrl":99},".claude-plugin\u002Fplugin.json",708,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002F.claude-plugin\u002Fplugin.json",{"path":101,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":102,"sourceHtmlUrl":103},"docs\u002FAPI_RECIPES.md",16480,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FAPI_RECIPES.md",{"path":105,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":106,"sourceHtmlUrl":107},"docs\u002FCALLDATA_GUIDE.md",9634,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FCALLDATA_GUIDE.md",{"path":109,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":110,"sourceHtmlUrl":111},"docs\u002FHEADLESS_SDK_RECIPES.md",9862,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FHEADLESS_SDK_RECIPES.md",{"path":113,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":114,"sourceHtmlUrl":115},"docs\u002FINTEGRATION_DECISION_TREE.md",4339,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FINTEGRATION_DECISION_TREE.md",{"path":117,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":118,"sourceHtmlUrl":119},"docs\u002FTRAILS_OVERVIEW.md",4326,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FTRAILS_OVERVIEW.md",{"path":121,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":122,"sourceHtmlUrl":123},"docs\u002FTROUBLESHOOTING.md",8795,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FTROUBLESHOOTING.md",{"path":125,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":126,"sourceHtmlUrl":127},"docs\u002FWIDGET_RECIPES.md",7432,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fdocs\u002FWIDGET_RECIPES.md",{"path":129,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":130,"sourceHtmlUrl":131},"README.md",9821,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002FREADME.md",{"path":133,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":136,"sourceHtmlUrl":137},"snippets\u002Fcalldata-viem.ts","SCRIPT","脚本",10347,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fsnippets\u002Fcalldata-viem.ts",{"path":139,"resourceType":134,"resourceTypeDesc":135,"sizeBytes":140,"sourceHtmlUrl":141},"snippets\u002Fnode-api.ts",14640,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fsnippets\u002Fnode-api.ts",{"path":143,"resourceType":144,"resourceTypeDesc":145,"sizeBytes":146,"sourceHtmlUrl":147},"snippets\u002Freact-headless.tsx","OTHER","其他",10046,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fsnippets\u002Freact-headless.tsx",{"path":149,"resourceType":144,"resourceTypeDesc":145,"sizeBytes":150,"sourceHtmlUrl":151},"snippets\u002Freact-widget.tsx",5870,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fjameslawton\u002Ftrails\u002Fsnippets\u002Freact-widget.tsx",[153,177,201,219,224,244],{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":37},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[160,161,33,162,23,163,164,165,166,167,168,169,170,171,172,173,174,175,176],"crowd prompting","prompting","with","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","https","content","ai agents",{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":183,"publishedAt":37},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[184,33,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,165,200],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking","use",{"skillNo":202,"name":203,"nameZh":6,"description":204,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":205,"categories":206,"keywords":207,"publishedAt":37},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[],[208,209,210,211,212,213,214,162,215,198,200,216,33,217,218],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":220,"name":203,"nameZh":6,"description":204,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":221,"categories":222,"keywords":223,"publishedAt":37},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[211,210,209,208,218,213,214,162,212,198,200,215,216,33,217],{"skillNo":225,"name":226,"nameZh":6,"description":227,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":228,"categories":229,"keywords":230,"publishedAt":37},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[231,232,233,234,235,236,237,238,239,240,241,242,243],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":245,"name":246,"nameZh":6,"description":247,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":248,"categories":249,"keywords":250,"publishedAt":37},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[],[251,252,253,254,162,255,256,69,257,216,258,259,260,261,262,174,263,264,265],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]