XY Finance

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

Example Request

$ curl https://open-api.xy.finance/v1/swap?srcChainId=1&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&amount=500000000000000000&destChainId=56&toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&slippage=1&referrer=0x8c6bDCb8c66fe5BFAa82510413665833FCFa08Ee&receiveAddress=0xbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef
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.


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