All Skills

Swap API

The recommended integration path. Covers GET /swap/approval for crosschain swaps and POST /swap/approval for embedded actions. Includes trade types, slippage, error codes, and end-to-end code examples.

Edit

Swap API Deep-Dive

The Swap API (/swap/approval) is the recommended integration path for most developers. It abstracts swap + bridge + swap into a single call and returns executable calldata.

Base URLs

Integrator ID (required for production)

Before launch, register and obtain your 2-byte hex integrator ID (e.g., 0xdead). This ID is used for tracking and support.

Caching and Liveness

Trade Types

Slippage

GET /swap/approval

Returns data required to execute a crosschain swap. If the input token requires approval, approvalTxns is included.

Required query parameters

ParameterDescription
tradeTypeexactInput, minOutput, or exactOutput
amountRequired amount in smallest units. For exactInput, this is the input amount; otherwise it is the output amount
inputTokenInput token address on origin chain
outputTokenOutput token address on destination chain
originChainIdOrigin chain ID
destinationChainIdDestination chain ID
depositorAddress initiating the swap

Optional query parameters

ParameterDescription
recipientAddress receiving output token (defaults to depositor)
appFeeIntegrator fee percentage (0 to 1), denominated in output token
appFeeRecipientAddress receiving app fees (required if appFee is set)
integratorId2-byte hex string identifying the integrator (e.g., 0xdead)
refundAddressAddress to receive refunds (defaults to depositor)
refundOnOriginBoolean override for refund chain. If omitted, defaults depend on route type (B2B/A2B => origin; B2A/A2A => destination). Refund recipient priority: refundAddress > recipient > depositor
slippageauto (default) or numeric decimal between 0 and 1
skipOriginTxEstimationIf true, skip origin swap estimation. Defaults differ between description and schema; set explicitly to avoid ambiguity
strictTradeTypeIf true, strictly follow the provided tradeType
excludeSourcesArray of swap sources to exclude (see /swap/sources)
includeSourcesArray of swap sources to include (see /swap/sources)

Response (key fields)

Errors

POST /swap/approval (embedded actions)

Use this to build embedded crosschain actions that execute on the destination chain immediately after the swap.

Request body

{
  "actions": [
    {
      "target": "0x...",
      "functionSignature": "function transfer(address,uint256)",
      "args": [
        { "value": "0xRecipient", "populateDynamically": false },
        { "value": "0", "populateDynamically": true, "balanceSourceToken": "0xToken" }
      ],
      "value": "0",
      "isNativeTransfer": false
    }
  ]
}

Notes

End-to-End Example: Bridge USDC from Arbitrum to Base

This example shows the complete flow for a crosschain USDC transfer.

1. Get a quote

GET https://app.across.to/api/swap/approval?tradeType=exactInput&amount=10000000&inputToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&outputToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&originChainId=42161&destinationChainId=8453&depositor=0xYourAddress&slippage=auto

2. Check for approval transactions

If the response includes approvalTxns, submit each one and wait for confirmation before proceeding.

for (const approvalTx of response.approvalTxns) {
  const tx = await wallet.sendTransaction({
    to: approvalTx.to,
    data: approvalTx.data,
    chainId: approvalTx.chainId,
  });
  await tx.wait();
}

3. Submit the swap transaction

const swapTx = await wallet.sendTransaction({
  to: response.swapTx.to,
  data: response.swapTx.data,
  chainId: response.swapTx.chainId,
  gasLimit: response.swapTx.gas,
});
const receipt = await swapTx.wait();

4. Track the deposit

GET https://app.across.to/api/deposit/status?depositTxnRef={receipt.transactionHash}

Poll every 10 seconds until status = "filled".

Related endpoints

GET /swap/chains
GET /swap/tokens
GET /swap/sources
GET /swap/sources?chainId={id}

Use these to populate UIs and validate inputs before calling /swap/approval.