### Install Dependencies Source: https://docs.across.to/guides/dev-guides/crosschain-aave-deposit Initialize a Node.js project and install the viem library. ```bash npm init -y npm install viem ``` -------------------------------- ### Self-Host MCP Server - Setup Source: https://docs.across.to/ai-agents/mcp-server Clone the MCP server repository, install dependencies, and build the project for local hosting. ```bash git clone https://github.com/across-protocol/mcp-server-across.git cd mcp-server-across npm install npm run build ``` -------------------------------- ### Install Dependencies and Build Relayer - Shell Source: https://docs.across.to/introduction/security/disputing-root-bundles Clone the Across relayer repository and install its dependencies using yarn. This is the initial setup step for automated disputes. ```shell git clone https://github.com/across-protocol/relayer-v3.git cd relayer-v3 yarn install && yarn build ``` -------------------------------- ### Bridge and Swap URL Examples Source: https://docs.across.to/guides/user-guides/direct-route-linking Examples of constructing URLs with query parameters to pre-fill bridge routes. ```text https://app.across.to/bridge-and-swap?from=8453&to=42161&inputToken=USDC&outputToken=USDC ``` ```text https://app.across.to/bridge-and-swap?from=8453&to=42161&inputToken=BAL&outputToken=USDC ``` ```text https://app.across.to/bridge-and-swap?from=8453 ``` ```text https://app.across.to/bridge-and-swap?from=1&to=10&inputToken=ETH&outputToken=ETH ``` -------------------------------- ### Clone and Build Across Relayer Source: https://docs.across.to/introduction/security/validating-root-bundles Clone the Across relayer repository and install dependencies. This is the initial setup step for running a validator. ```bash git clone https://github.com/across-protocol/relayer-v3.git cd relayer-v3 yarn install && yarn build ``` -------------------------------- ### Full TypeScript Example for Swap and Transfer Source: https://docs.across.to/introduction/embedded-actions/transfer-erc20 This example demonstrates how to perform a swap and then transfer the acquired ERC-20 tokens to a specified recipient using viem and Across API. Ensure you have the necessary RPC endpoints and private key configured. ```typescript import { createWalletClient, createPublicClient, http, parseUnits } from "viem"; import { arbitrum } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const walletClient = createWalletClient({ account, chain: arbitrum, transport: http(), }); const publicClient = createPublicClient({ chain: arbitrum, transport: http(), }); // MulticallHandler on Arbitrum const MULTICALL_HANDLER = "0x924a9f036260DdD5808007E1AA95f08eD08aA569"; // USDC on Arbitrum const USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"; // Final recipient for the tokens const FINAL_RECIPIENT = "0x718648C8c531F91b528A7757dD2bE813c3940608"; async function swapAndTransfer() { const params = new URLSearchParams({ tradeType: "exactInput", originChainId: "8453", // Base destinationChainId: "42161", // Arbitrum inputToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base outputToken: USDC_ARBITRUM, amount: parseUnits("100", 6).toString(), depositor: account.address, recipient: MULTICALL_HANDLER, }); const response = await fetch( `https://app.across.to/api/swap/approval?${params}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ actions: [ { target: USDC_ARBITRUM, functionSignature: "function transfer(address to, uint256 value)", args: [ { value: FINAL_RECIPIENT, populateDynamically: false }, { value: "0", populateDynamically: true, balanceSourceToken: USDC_ARBITRUM, }, ], value: "0", isNativeTransfer: false, populateCallValueDynamically: false, }, ], }), } ); const quote = await response.json(); // Execute approvals if (quote.approvalTxns?.length) { for (const approvalTx of quote.approvalTxns) { const hash = await walletClient.sendTransaction({ to: approvalTx.to, data: approvalTx.data, }); await publicClient.waitForTransactionReceipt({ hash }); } } // Execute swap const hash = await walletClient.sendTransaction({ to: quote.swapTx.to, data: quote.swapTx.data, value: quote.swapTx.value ? BigInt(quote.swapTx.value) : 0n, }); console.log("Swap + transfer tx:", hash); } swapAndTransfer(); ``` -------------------------------- ### Sample Token Response Source: https://docs.across.to/guides/dev-guides/integrate-swap-api Example JSON response from the /swap/tokens endpoint. ```json [ { "chainId": 42161, "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "name": "USD Coin", "symbol": "USDC", "decimals": 6, "priceUsd": "0.999903" }, { "chainId": 42161, "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "name": "Wrapped Ether", "symbol": "WETH", "decimals": 18, "priceUsd": "1937.75" } ] ``` -------------------------------- ### API Response Examples Source: https://docs.across.to/api-reference/suggested-fees/get Example JSON responses for successful fee estimation and common error scenarios. ```json { "estimatedFillTimeSec": 2, "capitalFeePct": "78750000000001", "capitalFeeTotal": "78750000000001", "relayGasFeePct": "155024308002", "relayGasFeeTotal": "155024308002", "relayFeePct": "78905024308003", "relayFeeTotal": "78905024308003", "lpFeePct": "0", "timestamp": "1754342087", "isAmountTooLow": false, "quoteBlock": "23070320", "exclusiveRelayer": "0x394311A6Aaa0D8E3411D8b62DE4578D41322d1bD", "exclusivityDeadline": 1754342267, "spokePoolAddress": "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5", "destinationSpokePoolAddress": "0x6f26Bf09B1C792e3228e5467807a900A503c0281", "totalRelayFee": { "pct": "78905024308003", "total": "78905024308003" }, "relayerCapitalFee": { "pct": "78750000000001", "total": "78750000000001" }, "relayerGasFee": { "pct": "155024308002", "total": "155024308002" }, "lpFee": { "pct": "0", "total": "0" }, "limits": { "minDeposit": "134862494200912", "maxDeposit": "1661211802629989209324", "maxDepositInstant": "231397155893653275446", "maxDepositShortDelay": "1661211802629989209324", "recommendedDepositInstant": "231397155893653275446" }, "fillDeadline": "1754353917", "outputAmount": "999921094975691997", "inputToken": { "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "symbol": "ETH", "decimals": 18, "chainId": 1 }, "outputToken": { "address": "0x4200000000000000000000000000000000000006", "symbol": "ETH", "decimals": 18, "chainId": 10 }, "id": "xn8fx-1754342218143-67be35cfbdb6" } ``` ```json { "type": "AcrossApiError", "code": "AMOUNT_TOO_HIGH", "status": 400, "message": "Amount exceeds max. deposit limit- 20003.800721 USDzC" } ``` ```json { "type": "AcrossApiError", "code": "INTERNAL_SERVER_ERROR", "status": 500, "message": "Internal server error" } ``` -------------------------------- ### Sample Chain Response Source: https://docs.across.to/guides/dev-guides/integrate-swap-api Example JSON response from the /swap/chains endpoint. ```json [ { "chainId": 42161, "name": "Arbitrum", "publicRpcUrl": "https://arb1.arbitrum.io/rpc", "explorerUrl": "https://arbiscan.io" }, { "chainId": 8453, "name": "Base", "publicRpcUrl": "https://mainnet.base.org", "explorerUrl": "https://basescan.org" } ] ``` -------------------------------- ### Full TypeScript Example for Swap and ETH Transfer Source: https://docs.across.to/introduction/embedded-actions/native-eth-transfer A complete TypeScript example demonstrating how to swap tokens crosschain to ETH and then transfer the native ETH to a recipient address using the Across protocol. Requires viem for blockchain interactions. ```typescript import { createWalletClient, createPublicClient, http, parseUnits } from "viem"; import { arbitrum } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const walletClient = createWalletClient({ account, chain: arbitrum, transport: http(), }); const publicClient = createPublicClient({ chain: arbitrum, transport: http(), }); const MULTICALL_HANDLER_ETH = "0x924a9f036260DdD5808007E1AA95f08eD08aA569"; const ETH_RECIPIENT = "0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB"; async function swapAndTransferEth() { const params = new URLSearchParams({ tradeType: "exactInput", originChainId: "42161", // Arbitrum destinationChainId: "1", // Ethereum inputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum outputToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH on Ethereum amount: parseUnits("200", 6).toString(), depositor: account.address, recipient: MULTICALL_HANDLER_ETH, }); const response = await fetch( `https://app.across.to/api/swap/approval?${params}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ actions: [ { target: ETH_RECIPIENT, functionSignature: "", args: [], value: "0", isNativeTransfer: true, populateCallValueDynamically: true, }, ], }), } ); const quote = await response.json(); if (quote.approvalTxns?.length) { for (const approvalTx of quote.approvalTxns) { const hash = await walletClient.sendTransaction({ to: approvalTx.to, data: approvalTx.data, }); await publicClient.waitForTransactionReceipt({ hash }); } } const hash = await walletClient.sendTransaction({ to: quote.swapTx.to, data: quote.swapTx.data, value: quote.swapTx.value ? BigInt(quote.swapTx.value) : 0n, }); console.log("Swap + ETH transfer tx:", hash); } swapAndTransferEth(); ``` -------------------------------- ### API Response Examples Source: https://docs.across.to/api-reference/deposit/get Examples of successful and error response bodies returned by the API. ```json { "deposit": { "id": 73606, "relayHash": null, "depositId": null, "originChainId": 1, "destinationChainId": 8453, "depositor": "0x0F7Ae28dE1C8532170AD4ee566B5801485c13a0E", "recipient": "0x133243d447026345c2B368d7fFe435dbe3C566Eb", "exclusiveRelayer": null, "inputToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "inputAmount": "1100250000000", "outputToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "outputAmount": "1100139975000", "swapOutputToken": null, "swapOutputTokenAmount": null, "message": "0xd4aee56e...", "messageHash": null, "exclusivityDeadline": null, "fillDeadline": null, "quoteTimestamp": "2026-04-01T16:10:35.000Z", "depositTxHash": "0x6cc666b81183d7386507508d82915afe81bf0bf641e86547dc602bc6af4fde32", "depositTxnRef": "0x6cc666b81183d7386507508d82915afe81bf0bf641e86547dc602bc6af4fde32", "depositBlockNumber": 24785853, "depositBlockTimestamp": "2026-04-01T16:10:35.000Z", "status": "filled", "depositRefundTxHash": null, "depositRefundTxnRef": null, "swapTokenPriceUsd": null, "swapFeeUsd": null, "bridgeFeeUsd": "110.025", "inputPriceUsd": null, "outputPriceUsd": null, "fillGasFee": null, "fillGasFeeUsd": null, "fillGasTokenPriceUsd": null, "actionsSucceeded": null, "actionsTargetChainId": null, "swapTransactionHash": null, "swapToken": null, "swapTokenAmount": null, "relayer": null, "fillBlockNumber": 44135258, "fillBlockTimestamp": "2026-04-01T16:11:03.000Z", "fillTx": "0x85dd6122644779d9b369861a6e4fff8330c9eab1b1f1e44490bd2003e1314c78", "fillTxnRef": "0x85dd6122644779d9b369861a6e4fff8330c9eab1b1f1e44490bd2003e1314c78", "speedups": [ {} ] }, "pagination": { "currentIndex": 0, "maxIndex": 0 } } ``` ```json { "message": "Must provide at least one of: (depositId + originChainId), depositTxHash, depositTxnRef, or relayDataHash" } ``` ```json { "message": "string" } ``` ```json { "message": "string" } ``` -------------------------------- ### Integrator ID Format Examples Source: https://docs.across.to/introduction/api-keys Examples of valid and invalid integrator ID formats for query parameters. ```text 0xdead ✓ Valid 0x0001 ✓ Valid 0xffff ✓ Valid dead ✗ Missing 0x prefix 0xdeadbeef ✗ Too long (4 bytes) ``` -------------------------------- ### API Response Examples Source: https://docs.across.to/api-reference/swap/tokens/get Example JSON payloads for successful token retrieval and common API error responses. ```json [ { "chainId": 1, "address": "0x111111111117dC0aa78b770fA6A738034120C302", "name": "1inch", "symbol": "1INCH", "decimals": 18, "logoUrl": "https://assets.coingecko.com/coins/images/13469/thumb/1inch-token.png?1608803028", "priceUsd": "0.2530907825982632" }, { "chainId": 1, "address": "0xB98d4C97425d9908E66E53A6fDf673ACcA0BE986", "name": "Arcblock", "symbol": "ABT", "decimals": 18, "logoUrl": "https://assets.coingecko.com/coins/images/2341/thumb/arcblock.png?1547036543", "priceUsd": "0.7697036684522818" }, { "chainId": 1, "address": "0xEd04915c23f00A313a544955524EB7DBD823143d", "name": "Alchemy Pay", "symbol": "ACH", "decimals": 8, "logoUrl": "https://assets.coingecko.com/coins/images/12390/thumb/ACH_%281%29.png?1599691266", "priceUsd": "0.02048510218654289" } ] ``` ```json { "type": "AcrossApiError", "code": "INVALID_REQUEST", "status": 400, "message": "Invalid request parameters" } ``` ```json { "type": "AcrossApiError", "code": "INTERNAL_SERVER_ERROR", "status": 500, "message": "Internal server error" } ``` -------------------------------- ### Fetching Page Index Source: https://docs.across.to/ai-agents/llms-txt Examples of how to fetch the page index (`/llms.txt`) using curl, Python, and Node.js. ```APIDOC ## Fetching Page Index ### `curl` ```bash curl https://docs.across.to/llms.txt ``` ### Python ```python import requests index = requests.get("https://docs.across.to/llms.txt").text print(index) ``` ### Node.js ```javascript const index = await fetch("https://docs.across.to/llms.txt").then(r => r.text()); console.log(index); ``` ``` -------------------------------- ### GET /swap/sources Source: https://docs.across.to/api-reference/swap/sources/get Retrieves a list of all supported sources that support crosschain swaps on the Across Protocol. ```APIDOC ## GET /swap/sources ### Description Returns a list of all supported sources that support crosschain swaps on Across Protocol. ### Method GET ### Endpoint https://app.across.to/api/swap/sources ### Parameters #### Query Parameters - **chainId** (integer) - Optional - Chain ID of the chain to get supported sources for. Range: 1 <= value. ### Request Example curl -X GET "https://app.across.to/api/swap/sources?chainId=1" -H "Authorization: Bearer " ### Response #### Success Response (200) - **Array** (string) - List of supported source identifiers. #### Response Example [ "0x_rfq", "1inch", "angle" ] ``` -------------------------------- ### Successful API response format Source: https://docs.across.to/api-reference/swap/sources/get Example of a successful JSON response containing a list of supported swap sources. ```json [ "0x_rfq", "1inch", "angle", "arbswap", "balancer", "balancer_v2", "balancer_v3", "camelot", "camelot_v2", "camelot_v3", "..." ] ``` -------------------------------- ### Generating Order Data with viem Source: https://docs.across.to/guides/concepts/erc-7683 Example using viem's `encodeAbiParameters` to construct the `orderData` for a crosschain intent. ```typescript import { encodeAbiParameters, parseAbiParameters } from "viem"; const orderData = encodeAbiParameters( parseAbiParameters([ "address outputToken", "uint256 outputAmount", "uint256 destinationChainId", "address recipient", "address exclusiveRelayer", "uint32 exclusivityDeadline", "bytes message", ]), [ "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base 1000000n, // 1 USDC (6 decimals) 8453n, // Base "0xYourRecipientAddress", "0x0000000000000000000000000000000000000000", // No exclusive relayer 0, "0x", // No message ] ); console.log(orderData); ``` -------------------------------- ### Full Integration Example: Generate Order Data Source: https://docs.across.to/guides/concepts/erc-7683 Encodes intent parameters to generate the `orderData` required for the `open()` function, using viem. ```typescript import { encodeAbiParameters, parseAbiParameters } from "viem"; const fillDeadline = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now const orderDataType = "0x9df4b782e7bbc178b3b93bfe8aafb909e84e39484d7f3c59f400f1b4691f85e2"; const orderData = encodeAbiParameters( parseAbiParameters([ "address outputToken", "uint256 outputAmount", "uint256 destinationChainId", "address recipient", "address exclusiveRelayer", "uint32 exclusivityDeadline", "bytes message", ]), [ "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum 100000000n, // 100 USDC 42161n, // Arbitrum account.address, "0x0000000000000000000000000000000000000000", 0, "0x", ] ); console.log(orderData); ``` -------------------------------- ### Clone Relayer Repository and Set Up Environment Source: https://docs.across.to/introduction/relayers/running-relayer Clone the relayer-v3 GitHub repository and create a secure .env file for sensitive configuration. Ensure file permissions are restricted. ```bash git clone https://github.com/across-protocol/relayer-v3.git cd relayer-v3 touch .env chmod 0600 .env ``` -------------------------------- ### Example Prompt for Bridging Tokens Source: https://docs.across.to/ai-agents An example natural language prompt to instruct an AI agent, equipped with Across skills, to bridge tokens between chains. ```plaintext Bridge 100 USDC from Arbitrum to Base ``` -------------------------------- ### Get a Quote for a Crosschain Swap Source: https://docs.across.to/introduction Call the Swap API to get executable calldata for a crosschain swap. Ensure you have an API key and integrator ID for production use. ```typescript const params = new URLSearchParams({ tradeType: "minOutput", originChainId: "42161", // Arbitrum destinationChainId: "8453", // Base inputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum outputToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base amount: "1000000000", // 1000 USDC (6 decimals) depositor: "0xYourWalletAddress", integratorId: "0xdead", // Your integrator ID }); const response = await fetch( `https://app.across.to/api/swap/approval?${params}`, { headers: { Authorization: "Bearer YOUR_API_KEY", }, } ); const quote = await response.json(); ``` -------------------------------- ### Fetching Full Documentation Dump Source: https://docs.across.to/ai-agents/llms-txt Examples of how to fetch the full documentation dump (`/llms-full.txt`) using curl, Python, and Node.js. ```APIDOC ## Fetching Full Documentation Dump ### `curl` ```bash curl https://docs.across.to/llms-full.txt ``` ### Python ```python import requests full = requests.get("https://docs.across.to/llms-full.txt").text print(full) ``` ### Node.js ```javascript const full = await fetch("https://docs.across.to/llms-full.txt").then(r => r.text()); console.log(full); ``` ``` -------------------------------- ### Create Integration File Source: https://docs.across.to/guides/dev-guides/integrate-swap-api Create the bridge.ts file for the integration. ```bash touch bridge.ts ``` -------------------------------- ### Swap and Deposit to Aave on Arbitrum Source: https://docs.across.to/introduction/embedded-actions/deposit-eth-aave This example demonstrates how to swap USDC on Arbitrum for WETH on Ethereum and then deposit the WETH into Aave. The `populateCallValueDynamically: true` option is crucial for forwarding the native ETH from the swap as `msg.value` to the `depositETH` function. ```typescript import { createWalletClient, createPublicClient, http, parseUnits } from "viem"; import { arbitrum } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const walletClient = createWalletClient({ account, chain: arbitrum, transport: http(), }); const publicClient = createPublicClient({ chain: arbitrum, transport: http(), }); const MULTICALL_HANDLER = "0x924a9f036260DdD5808007E1AA95f08eD08aA569"; const AAVE_WETH_GATEWAY = "0x5283BEcEd7ADF6D003225C13896E536f2D4264FF"; const DEPOSIT_BENEFICIARY = "0x718648C8c531F91b528A7757dD2bE813c3940608"; async function swapAndDepositToAave() { const params = new URLSearchParams({ tradeType: "exactInput", originChainId: "42161", // Arbitrum destinationChainId: "1", // Ethereum inputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum outputToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH on Ethereum amount: parseUnits("500", 6).toString(), depositor: account.address, recipient: MULTICALL_HANDLER, }); const response = await fetch( `https://app.across.to/api/swap/approval?${params}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ actions: [ { target: AAVE_WETH_GATEWAY, functionSignature: "function depositETH(address, address onBehalfOf, uint16 referralCode)", args: [ { value: "0x0000000000000000000000000000000000000000", populateDynamically: false, }, { value: DEPOSIT_BENEFICIARY, populateDynamically: false, }, { value: "0", populateDynamically: false, }, ], value: "0", isNativeTransfer: false, populateCallValueDynamically: true, }, ], }), } ); const quote = await response.json(); if (quote.approvalTxns?.length) { for (const approvalTx of quote.approvalTxns) { const hash = await walletClient.sendTransaction({ to: approvalTx.to, data: approvalTx.data, }); await publicClient.waitForTransactionReceipt({ hash }); } } const hash = await walletClient.sendTransaction({ to: quote.swapTx.to, data: quote.swapTx.data, value: quote.swapTx.value ? BigInt(quote.swapTx.value) : 0n, }); console.log("Swap + Aave deposit tx:", hash); } swapAndDepositToAave(); ``` -------------------------------- ### Fetching Single Page Source: https://docs.across.to/ai-agents/llms-txt Examples of how to fetch a single documentation page (e.g., Swap API docs) as markdown using curl, Python, and Node.js. ```APIDOC ## Fetching Single Page ### `curl` ```bash # Fetch the Swap API docs as markdown curl https://docs.across.to/introduction/swap-api.mdx ``` ### Python ```python import requests page = requests.get("https://docs.across.to/introduction/swap-api.mdx").text print(page) ``` ### Node.js ```javascript const page = await fetch("https://docs.across.to/introduction/swap-api.mdx") .then(r => r.text()); console.log(page); ``` ``` -------------------------------- ### Get deposit details Source: https://docs.across.to/api-reference Retrieves detailed information for a specific deposit. ```APIDOC ## GET /deposit ### Description Get all details for a single deposit. ### Method GET ### Endpoint `/deposit` ``` -------------------------------- ### Execute Cross-Chain Swap with viem Source: https://docs.across.to/introduction/swap-api Demonstrates the full swap flow using viem, including fetching a quote, handling token approvals, and executing the swap transaction. ```typescript import { createWalletClient, createPublicClient, http, parseUnits } from "viem"; import { arbitrum } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const walletClient = createWalletClient({ account, chain: arbitrum, transport: http(), }); const publicClient = createPublicClient({ chain: arbitrum, transport: http(), }); async function executeSwap() { // 1. Get quote const params = new URLSearchParams({ tradeType: "minOutput", originChainId: "42161", destinationChainId: "8453", inputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum outputToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base amount: parseUnits("100", 6).toString(), // 100 USDC depositor: account.address, integratorId: "0xdead", }); const res = await fetch( `https://app.across.to/api/swap/approval?${params}`, { headers: { Authorization: "Bearer YOUR_API_KEY", }, } ); const quote = await res.json(); if (!quote.swapTx) { throw new Error(`Quote failed: ${JSON.stringify(quote)}`); } // 2. Execute approval transactions if (quote.approvalTxns?.length) { for (const approvalTx of quote.approvalTxns) { const hash = await walletClient.sendTransaction({ to: approvalTx.to, data: approvalTx.data, }); await publicClient.waitForTransactionReceipt({ hash }); console.log("Approval confirmed:", hash); } } // 3. Execute swap const hash = await walletClient.sendTransaction({ to: quote.swapTx.to, data: quote.swapTx.data, value: quote.swapTx.value ? BigInt(quote.swapTx.value) : 0n, gas: quote.swapTx.gas ? BigInt(quote.swapTx.gas) : undefined, }); console.log("Swap tx:", hash); console.log("Expected fill:", quote.expectedFillTime, "seconds"); return hash; } executeSwap(); ``` -------------------------------- ### GET /deposit/status Source: https://docs.across.to/introduction/deposit-addresses Polls the status of a deposit made to a generated counterfactual address. ```APIDOC ## GET /deposit/status ### Description Monitors the progress of a deposit transfer to a counterfactual address. ### Method GET ### Endpoint /deposit/status ### Parameters #### Query Parameters - **depositAddress** (string) - Required - The generated deposit address - **index** (number) - Required - The index of the deposit ### Response #### Success Response (200) - **status** (string) - Current status of the deposit - **depositTxnRef** (string) - Transaction reference for the deposit ``` -------------------------------- ### GET /suggested-fees/deposit-address Source: https://docs.across.to/api-reference/swap/approval/get Generates a counterfactual deposit address for initiating crosschain transfers. ```APIDOC ## GET /suggested-fees/deposit-address ### Description Returns a counterfactual deposit address that the user can send funds to in order to initiate a crosschain transfer. This address is deterministically computed based on the swap parameters. ### Method GET ### Endpoint /suggested-fees/deposit-address ``` -------------------------------- ### Build and Test Commands Source: https://docs.across.to/ai-agents/agents-md Placeholder section for project-specific build and test commands within the AGENTS.md file. ```bash [your install command, e.g., pnpm install] [your build command, e.g., pnpm build] [your test command, e.g., pnpm test] [your dev command, e.g., pnpm dev] ``` -------------------------------- ### Execute Swap and Add Liquidity via TypeScript Source: https://docs.across.to/introduction/embedded-actions/hubpool-liquidity Full TypeScript implementation using viem to fetch a crosschain swap quote and execute the resulting transactions. ```typescript import { createWalletClient, createPublicClient, http, parseUnits } from "viem"; import { arbitrum } from "viem/chains"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const walletClient = createWalletClient({ account, chain: arbitrum, transport: http(), }); const publicClient = createPublicClient({ chain: arbitrum, transport: http(), }); const MULTICALL_HANDLER_ETH = "0x924a9f036260DdD5808007E1AA95f08eD08aA569"; const HUBPOOL = "0xc186fA914353c44b2E33eBE05f21846F1048bEda"; const WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; async function swapAndAddLiquidity() { const params = new URLSearchParams({ tradeType: "exactInput", originChainId: "42161", // Arbitrum destinationChainId: "1", // Ethereum inputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum outputToken: WETH, amount: parseUnits("1000", 6).toString(), depositor: account.address, recipient: MULTICALL_HANDLER_ETH, }); const response = await fetch( `https://app.across.to/api/swap/approval?${params}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ actions: [ { target: HUBPOOL, functionSignature: "function addLiquidity(address l1Token, uint256 l1TokenAmount)", args: [ { value: WETH, populateDynamically: false, }, { value: "0", populateDynamically: true, balanceSourceToken: "0x0000000000000000000000000000000000000000", }, ], value: "0", isNativeTransfer: false, populateCallValueDynamically: true, }, ], }), } ); const quote = await response.json(); if (quote.approvalTxns?.length) { for (const approvalTx of quote.approvalTxns) { const hash = await walletClient.sendTransaction({ to: approvalTx.to, data: approvalTx.data, }); await publicClient.waitForTransactionReceipt({ hash }); } } const hash = await walletClient.sendTransaction({ to: quote.swapTx.to, data: quote.swapTx.data, value: quote.swapTx.value ? BigInt(quote.swapTx.value) : 0n, }); console.log("Swap + HubPool liquidity tx:", hash); } swapAndAddLiquidity(); ``` -------------------------------- ### GET /api/swap/chains Source: https://docs.across.to/api-reference/swap/chains/get Retrieves a list of all supported chains for swapping on the Across Protocol. ```APIDOC ## GET /api/swap/chains ### Description Retrieves a list of all supported chains for swapping on the Across Protocol. This endpoint returns an array of chain objects, each containing details like chain ID, name, RPC URLs, and explorer links. ### Method GET ### Endpoint /api/swap/chains ### Parameters None ### Request Example ```bash curl -X GET "https://app.across.to/api/swap/chains" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **chainId** (integer) - The unique identifier for the blockchain. - **name** (string) - The human-readable name of the blockchain. - **publicRpcUrl** (string) - The URL for a public RPC endpoint. - **explorerUrl** (string) - The base URL for the blockchain's block explorer. - **logoUrl** (string) - The URL for the blockchain's logo. #### Response Example ```json [ { "chainId": 1, "name": "Ethereum", "publicRpcUrl": "https://mainnet.gateway.tenderly.co", "explorerUrl": "https://etherscan.io", "logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/scripts/chain-configs/mainnet/assets/logo.svg" }, { "chainId": 10, "name": "Optimism", "publicRpcUrl": "https://mainnet.optimism.io", "explorerUrl": "https://optimistic.etherscan.io", "logoUrl": "https://raw.githubusercontent.com/across-protocol/frontend/master/scripts/chain-configs/optimism/assets/logo.svg" } ] ``` ``` -------------------------------- ### Get all deposits for a depositor Source: https://docs.across.to/api-reference Retrieves a list of all deposits made by a specific depositor. ```APIDOC ## GET /deposits ### Description Get all deposits for a depositor. ### Method GET ### Endpoint `/deposits` ``` -------------------------------- ### Configure Swap API Refund Parameters Source: https://docs.across.to/introduction/refunds Example of setting refundAddress and refundOnOrigin parameters when constructing a request for the Across Swap API. ```typescript const params = new URLSearchParams({ tradeType: "minOutput", originChainId: "42161", destinationChainId: "8453", inputToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", outputToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amount: "1000000000", depositor: "0xYourWalletAddress", // Refund configuration refundAddress: "0xYourWalletAddress", // Where to send the refund refundOnOrigin: "true", // Refund on Arbitrum (origin) }); const response = await fetch( `https://app.across.to/api/swap/approval?${params}` ); ``` -------------------------------- ### RAG Pipeline Chunking Example Source: https://docs.across.to/ai-agents/llms-txt Python script to split the full documentation dump (`/llms-full.txt`) into per-page chunks based on H1 headings. ```APIDOC ## For RAG Pipelines ### Chunking Script (Python) ```python import requests full_text = requests.get("https://docs.across.to/llms-full.txt").text # Split into per-page chunks chunks = [] current_chunk = "" for line in full_text.split("\n"): if line.startswith("# ") and current_chunk: chunks.append(current_chunk.strip()) current_chunk = line + "\n" else: current_chunk += line + "\n" if current_chunk.strip(): chunks.append(current_chunk.strip()) print(f"Split into {len(chunks)} page chunks") ``` Each chunk corresponds to one documentation page and can be embedded independently for retrieval. ``` -------------------------------- ### Get supported tokens Source: https://docs.across.to/api-reference Retrieves a list of all supported tokens for crosschain swaps. ```APIDOC ## GET /swap/tokens ### Description Get supported tokens. ### Method GET ### Endpoint `/swap/tokens` ``` -------------------------------- ### Get supported chains Source: https://docs.across.to/api-reference Retrieves a list of all supported chains for crosschain operations. ```APIDOC ## GET /swap/chains ### Description Get supported chains. ### Method GET ### Endpoint `/swap/chains` ``` -------------------------------- ### GET /deposit Source: https://docs.across.to/introduction/deposit-addresses Retrieves full execution details for a completed deposit, including fees. ```APIDOC ## GET /deposit ### Description Retrieves full execution details for a deposit using the transaction reference. ### Method GET ### Endpoint /deposit ### Parameters #### Query Parameters - **depositTxnRef** (string) - Required - The transaction reference obtained from /deposit/status ### Response #### Success Response (200) - **fillTxnRef** (string) - The transaction reference for the fill on the destination chain ``` -------------------------------- ### Self-Host MCP Server - Docker Build and Run Source: https://docs.across.to/ai-agents/mcp-server Build the MCP server Docker image and run it, with an option for cache persistence. ```bash docker build -t mcp-server-across . docker run -i mcp-server-across ``` ```bash docker run -i -v across-mcp-cache:/root/.across-mcp mcp-server-across ```