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.
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
200
Swap approval data returned successfully.
application/json
400
Bad request due to invalid input parameter.
application/json
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
200
List of supported chains
application/json
400
Bad request
application/json
500
Internal server error
application/json
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
200
List of supported tokens
application/json
400
Bad request
application/json
500
Internal server error
application/json
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.