Cross Chain
This document will guide developers on how to integrate our service into their applications to facilitate querying the best route from token1 on Chain A to token2 on Chain B and assembling transactions.
Installation
To interact with SDK, we recommend installing through the npm package
Initialize
During initialization, two nodes are required: router and common, as well as a set of developer-private API keys and secret, which we need to obtain.
Integration Steps
To query route transaction data, the routes node needs to be set during initialization.
1.Query Supported Chain Info
Use the getChains function to query the list of all supported chains by this service. You will receive a list of blockchains' information.
Note: the chain info list may change over time as new chains are added or removed from the Router's support, please request this endpoint to get the latest supported chain info.
2. Query Best Routes
Use the getRoutes function to query the best routes from token1 on Chain A to token2 on Chain B. These routes are sorted by totalAmountOut of token2 in descending order.
E.g. find the best swap route from 1 ETH on Ethereum to USDT on BSC with 1% slippage and test as the entrance.
3. Assemble Transaction Data Based on Selected Route
Use the getOrders function to assemble transaction data based on the selected route hash from the getRoutes response.
E.g. assemble the transaction data based on the route hash 0x632f11788f1dc471afe15......6339d65fe03ad27a6b4daa75dc0ba with the slippage of 1% and the sender address Address1..... and the receiver address Address2..... .
Query
To query detail data, the common node needs to be set during initialization.
1. Transaction Detail
Use getTransaction function to retrieve the details of successfully sent transactions by using the transaction hash from the source chain.
2. Transaction List
Use getTransactions function to retrieve a list of successfully sent transactions from the wallet address on the source chain.
Finally
Congratulations! You have successfully used the SDK to complete the transaction and query the transaction data.
Last updated