4️⃣Build Swap Transaction
When building transaction, there are 6 additional parameters along with quote input.
receiver
Required
srcSwapProvider
Required when srcSwapDescription is presented in quote result
dstSwapProvider
Required when dstSwapDescription is presented in quote result
bridgeProvider
Required when bridgeDescription is presented in quote result
srcBridgeTokenAddress
Required when bridgeDescription is presented in quote result
dstBridgeTokenAddress
Required when bridgeDescription is presented in quote result
To build transaction, please fill the corresponding fields (srcSwapDescription
, bridgeDescription
and dstSwapDescription
) from quote response's route to buildTx input . If parameters are not filled properly, it may not return the desired routing result. You can review the transaction calldata route by checking route
field in buildTx response.
For example, following response is quote result of Arbitrum USDT to KCC native token.
srcSwapDescription
is null because these is no source chain swap needed in this route, so we don't have to fillsrcSwapProvider
when calling buildTx.We have a non-empty
bridgeDescription
because it's a cross-chain quote. We need to fill correspondingbridgeProvider
,srcBridgeTokenAddress
anddstBridgeTokenAddress
when calling buildTx. For single chain quote, we can skip these parameters.dstSwapDescription
is needed in this route. So we need to filldstSwapProvider
when calling buildTx.
Therefore, we can create the following buildTx request from above information:
Parameter/Response Details
Use
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
as the address for the native token in your parameter.If you would like to know more about commissionRate fields and fee collection function, please refer to Monetization / Take Fees
If you would like to know latest supported bridge provider and swap provider, please refer to Supported Blockchains/Bridges/DEXs
The
estimatedGas
field in the API response is an estimated value. For now, please use a method similar to RPC, such as eth_estimateGas, to re-estimate the actual gas limit. You can refer to the following sample code to do that:
Example Request
This request is asking to bridge 1 ETH from Optimism for ETH on the BNB Chain
IMPORTANT:
Note that the amount parameter should be padded with zeroes. For example, pass
100000000
instead of
100
if the decimals of the token is 6.
Here you can find our full API reference
Last updated