4️⃣Build Swap Transaction
Returns the swap data for bridging tokens
This API returns the details about the quote and the transaction that will trigger a single-chain or cross-chain swap request according to the quotation.
Get the swap transaction from the quote
GET
endpoint/swap
Parameters
Query Parameters
Name | Type | Description |
---|---|---|
srcChainId* | String | ID of source chain |
fromTokenAddress* | String | Token to be swapped from source chain |
amount* | String | Amount of tokens to be swapped and please consider the decimal and pad with zeroes for the amount. For example, pass 100000000 instead of 100 if the token has 6 decimal digits. |
destChainId* | String | ID of target chain |
toTokenAddress* | String | Token to be received on target chain |
receiveAddress* | String | Receiver of the swapped token on target chain |
slippage | String | Percentage of slippage tolerance ex: 1% you need to input 1 in the field |
referrer | String | Address of the referrer, this address will be used uniformly for any future partner incentive programs |
Example Request
This request is for a quote of 0.5 ETH on Ethereum to BNB on BNB Chain, with a 1% slippage and a referrer of 0x8c6bDCb8c66fe5BFAa82510413665833FCFa08Ee. The asset on the target chain will be eventually sent to 0xbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef.
Reminder
Before submitting a transaction, please ensure this following points
Note that the amount parameter should be padded with zeroes. For example, pass 100000000 instead of 100 if the decimal digits of the token are 6.
The chain you are on and the selected srcChainId are the same, to avoid sending the transaction to an unknown contract address to
The destChainId must be one of the chains supported by yBridge. If your destChainId is not supported by yBridge, the funds may be temporarily locked in the system. you could use Supported Blockchains to get latest list
Last updated