Swap & Cross-Chain
Swap
Estimation
This endpoint retrieves a list of decentralized exchanges (dexes) where the selected pair can be swapped. The list is sorted by profit, so we recommend choosing the first dex in the list.
Request
fromToken[address]
Address of source token
0x0000000000000000000000000000000000001010
fromToken[chainId]
Chain id of source token
137
fromToken[decimals]
Decimals of source token
18
fromToken[name]
Name of source token
Matic Token
fromToken[symbol]
Symbol of source token
MATIC
toToken[address]
Address of destination token
0x483dd3425278C1f79F377f1034d9d2CaE55648B6
toToken[chainId]
Chain id of destination token
137
toToken[decimals]
Decimals of destination token
18
toToken[name]
Name of destination token
Crowd Token
toToken[symbol]
Symbol of destination token
CROWD
amount
An amount of the source token to be swapped (The decimal of token must be considered in the amount)
1000000000000000000
Response
Transaction
This endpoint returns from
, to
, data
, value
, and gasLimit
, all of which needed for executing a swap.
A dex name must be added to the url. The dex name can be found in estimation response e.g., CrowdSwapV2, Quickswap
Request
fromToken[address]
Address of source token
0x0000000000000000000000000000000000001010
fromToken[chainId]
Chain id of source token
137
fromToken[decimals]
Decimals of source token
18
fromToken[name]
Name of source token
Matic Token
fromToken[symbol]
Symbol of source token
MATIC
toToken[address]
Address of destination token
0x483dd3425278C1f79F377f1034d9d2CaE55648B6
toToken[chainId]
Chain id of destination token
137
toToken[decimals]
Decimals of destination token
18
toToken[name]
Name of destination token
Crowd Token
toToken[symbol]
Symbol of destination token
CROWD
amount
An amount of input tokens to swap (the entrance amount must be based on token's decimal)
1000000000000000000
userAddress
Address of the user who initiates the swap transaction
any arbitrary address
receiverAddress
Address of the recipient if it is different from the userAddress
any arbitrary address
Response
Cross-Chain
Estimation and Transaction
This endpoint finds a route with potentially the best possible outcome for the requested cross-chain pair and returns an estimation.
Request
fromToken[address]
Address of source token
0x0000000000000000000000000000000000001010
fromToken[chainId]
Chain id of source token
137
fromToken[decimals]
Decimals of source token
18
fromToken[name]
Name of source token
Matic Token
fromToken[symbol]
Symbol of source token
MATIC
toToken[address]
Address of destination token
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
toToken[chainId]
Chain id of destination token
56
toToken[decimals]
Decimals of destination token
18
toToken[name]
Name of destination token
Binance Coin
toToken[symbol]
Symbol of destination token
BNB
amountIn
An amount of fromToken
to be swapped (The decimal of token must be considered in the amount)
1000000000000000000
userAddress
Address of the user who initiates the cross-chain swap transaction
any arbitrary address
Response
How to send a transaction
Both Swap
and Cross-Chain
APIs return the data needed for executing a transaction. The data, which named tx
in below code, contains from (user address)
, to (contract address)
, data (populated data)
, value (coin value if needed)
, gasLimit
. You can use below code to run your transaction.
To send a transaction, you can get tx
from the response of Swap and Cross-Chain end-points.
Last updated
Was this helpful?