Transfer ERC20 Tokens After Swap

This action demonstrates a common post-swap operation: transferring the newly acquired ERC20 tokens to a different address. The operation targets the ERC-20 token contract (target) and calls the transfer(address to, uint256 value) function. The recipient address is a static value, while the token amount is dynamically populated by setting populateDynamically: true and providing the token's contract address in balanceSourceToken. This effectively transfers the entire balance of the swapped token.

Request Body

{
  "actions": [
    {
      "target": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
      "functionSignature": "function transfer(address to, uint256 value)",
      "args": [
        {
          "value": "0x718648C8c531F91b528A7757dD2bE813c3940608",
          "populateDynamically": false
        },
        {
          "value": "0",
          "populateDynamically": true,
          "balanceSourceToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
        }
      ],
      "value": "0",
      "isNativeTransfer": false
    }
  ]
}

Get Swap Approval Details

post

Retrieves the required checks, transaction data, and fee information to execute a crosschain swap. This endpoint is called before executing the actual swap transaction.

Query parameters
tradeTypestringRequired

The type of trade.

Example: exactInput
amountstringRequired

The amount of the input token to be swapped, in its smallest unit (e.g., wei for ETH).

Example: 1000000000000000000
inputTokenstringRequired

The contract address of the token to be swapped.

Example: 0x4200000000000000000000000000000000000006
outputTokenstringRequired

The contract address of the token to be received.

Example: 0xaf88d065e77c8cC2239327C5EDb3A432268e5831
originChainIdintegerRequired

The chain ID of the source network.

Example: 10
destinationChainIdintegerRequired

The chain ID of the destination network.

Example: 42161
depositorstringRequired

The wallet address of the user initiating the swap.

Example: 0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
recipientstringRequired

The wallet address that will receive the swapped tokens. Can be the same as the depositor.

Example: 0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
Body
Responses
200

Successfully retrieved swap approval details.

application/json
post
POST /api/swap/approval HTTP/1.1
Host: app.across.to
Content-Type: application/json
Accept: */*
Content-Length: 372

{
  "actions": [
    {
      "target": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
      "functionSignature": "function transfer(address to, uint256 value)",
      "args": [
        {
          "value": "0x718648C8c531F91b528A7757dD2bE813c3940608",
          "populateDynamically": false
        },
        {
          "value": "0",
          "populateDynamically": true,
          "balanceSourceToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
        }
      ],
      "value": "0",
      "isNativeTransfer": false
    }
  ]
}
{
  "crossSwapType": "bridgeableToAny",
  "amountType": "exactInput",
  "checks": {
    "allowance": {
      "token": "0x4200000000000000000000000000000000000006",
      "spender": "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
      "actual": "0",
      "expected": "1000000000000000000"
    },
    "balance": {
      "token": "0x4200000000000000000000000000000000000006",
      "actual": "0",
      "expected": "1000000000000000000"
    }
  },
  "approvalTxns": [
    {
      "chainId": 10,
      "to": "0x4200000000000000000000000000000000000006",
      "data": "0x095ea7b30000000000000000000000006f26bf09b1c792e3228e5467807a900a503c0281ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
    }
  ],
  "steps": {
    "bridge": {
      "inputAmount": "1000000000000000000",
      "outputAmount": "999837229983721630",
      "tokenIn": {
        "decimals": 18,
        "symbol": "ETH",
        "address": "0x4200000000000000000000000000000000000006",
        "name": "Ether",
        "chainId": 10
      },
      "tokenOut": {
        "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
        "decimals": 18,
        "symbol": "ETH",
        "chainId": 42161
      },
      "fees": {
        "totalRelay": {
          "pct": "162770016278370",
          "total": "162770016278370"
        },
        "relayerCapital": {
          "pct": "78750000000001",
          "total": "78750000000001"
        },
        "relayerGas": {
          "pct": "36001936551324",
          "total": "36001936551324"
        },
        "lp": {
          "pct": "48018079727045",
          "total": "48018079727045"
        }
      }
    },
    "destinationSwap": {
      "tokenIn": {
        "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
        "decimals": 18,
        "symbol": "ETH",
        "chainId": 42161
      },
      "tokenOut": {
        "decimals": 6,
        "symbol": "USDC",
        "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "name": "USD Coin",
        "chainId": 42161
      },
      "inputAmount": "999837229983721630",
      "maxInputAmount": "999837229983721630",
      "outputAmount": "4774478065",
      "minOutputAmount": "4726725300",
      "swapProvider": {
        "name": "0x",
        "sources": [
          "pancakeswap_v3",
          "camelot_v3",
          "uniswap_v3",
          "uniswap_v4"
        ]
      }
    }
  },
  "inputToken": {
    "decimals": 18,
    "symbol": "ETH",
    "address": "0x4200000000000000000000000000000000000006",
    "name": "Ether",
    "chainId": 10
  },
  "outputToken": {
    "decimals": 6,
    "symbol": "USDC",
    "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    "name": "USD Coin",
    "chainId": 42161
  },
  "refundToken": {
    "decimals": 18,
    "symbol": "WETH",
    "address": "0x4200000000000000000000000000000000000006",
    "name": "Ether",
    "chainId": 10
  },
  "fees": {
    "total": {
      "amount": "16341920161670985",
      "amountUsd": "78.509852840699750232",
      "pct": "16341920161670985",
      "token": {
        "decimals": 18,
        "symbol": "ETH",
        "address": "0x4200000000000000000000000000000000000006",
        "name": "Ether",
        "chainId": 10
      }
    },
    "originGas": {
      "amount": "0",
      "amountUsd": "0.0",
      "token": {
        "chainId": 10,
        "address": "0x0000000000000000000000000000000000000000",
        "decimals": 18,
        "symbol": "ETH"
      }
    },
    "destinationGas": {
      "amount": "36001936551324",
      "amountUsd": "0.172347390600401718",
      "pct": "35874316348279",
      "token": {
        "chainId": 42161,
        "address": "0x0000000000000000000000000000000000000000",
        "decimals": 18,
        "symbol": "ETH"
      }
    },
    "relayerCapital": {
      "amount": "78750000000001",
      "amountUsd": "0.376989637500004804",
      "pct": "78470845822406",
      "token": {
        "decimals": 18,
        "symbol": "ETH",
        "address": "0x4200000000000000000000000000000000000006",
        "name": "Ether",
        "chainId": 10
      }
    },
    "lpFee": {
      "amount": "48018079727045",
      "amountUsd": "0.229870710726918032",
      "pct": "47847864519986",
      "token": {
        "decimals": 18,
        "symbol": "ETH",
        "address": "0x4200000000000000000000000000000000000006",
        "name": "Ether",
        "chainId": 10
      }
    },
    "relayerTotal": {
      "amount": "162770016278370",
      "amountUsd": "0.779207738827324525",
      "pct": "162193026690672",
      "token": {
        "decimals": 18,
        "symbol": "ETH",
        "address": "0x4200000000000000000000000000000000000006",
        "name": "Ether",
        "chainId": 10
      }
    },
    "app": {
      "amount": "0",
      "amountUsd": "0.0",
      "pct": "0",
      "token": {
        "decimals": 6,
        "symbol": "USDC",
        "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "name": "USD Coin",
        "chainId": 42161
      }
    }
  },
  "inputAmount": "1000000000000000000",
  "expectedOutputAmount": "4774478065",
  "minOutputAmount": "4726725300",
  "expectedFillTime": 2,
  "swapTx": {
    "simulationSuccess": false,
    "chainId": 10,
    "to": "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
    "data": "0xad5425c6000000000...",
    "maxFeePerGas": "1002599",
    "maxPriorityFeePerGas": "1000000"
  },
  "id": "c64fg-1755905774371-44a89a59ef9b"
}

Last updated