API Reference

This is a comprehensive walkthrough for developers looking to implement crosschain token swaps using the Across /swap/approval , /swap/chains and /swap/tokens API.

The ideal Across Crosschain Swap API approach involves setting an allowance and executing the transaction directly via the signer. This is a gasful flow.

Let's get started!


Get swap approval data

get
/swap/approval

Returns data required to execute a crosschain swap. If the input token requires approval, approvalTxns will be included in the response.

Query parameters
tradeTypestring · enumRequired

Type of trade. Use minOutput, exactInput or exactOutput.

Default: exactInputPossible values:
amountstringRequired

Required amount of output token in smallest unit.

Example: 1000000
inputTokenstringRequired

Address of the input token on the origin chain.

Example: 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85
outputTokenstringRequired

Address of the output token on the destination chain.

Example: 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
originChainIdintegerRequired

Chain ID of the origin chain.

Example: 10
destinationChainIdintegerRequired

Chain ID of the destination chain.

Example: 42161
depositorstringRequired

Address of the depositor initiating the swap.

Example: 0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
recipientstringRequired

Address of the account receiving the output token.

Example: 0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
integratorIdstringOptional

2-byte hex-string that identifies the integrator. E.g., "0xdead".

Example: 0xdead
refundAddressstringOptional

Address to receive refunds. Defaults to depositor if not provided.

Default: 0xDEPOSITOR_ADDRESS
refundOnOriginbooleanOptional

Specifies whether refund should be sent on the origin chain. Defaults to true.

Default: true
slippageTolerancenumber · floatOptional

Slippage tolerance percentage (e.g., 1 for 1%, 0.5 for 0.5%).

Default: 1
Responses
get
/swap/approval

Get supported chains for swap operations

get
/swap/chains

Returns a list of all supported blockchains that support crosschain swaps on Across Protocol.

Responses
get
/swap/chains

Get supported tokens for swap operations

get
/swap/tokens

Returns a list of all supported tokens that support crosschain swaps on Across Protocol.

Responses
get
/swap/tokens

With this, you have now completely understood the core principles of using the /swap endpoint. If you have any doubts, please feel free to reach out to us here.

Last updated