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
/swap/approval

Last updated