1.4 Examples

Request Example

{
  "id": 1742287332481,
  "fromChain": 43114,
  "toChain": 42161,
  "fromToken": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
  "toToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
  "fromAddress": "0x7521EDa00E2Ce05aC4a9d8353d096CCB970d5188",
  "toAddress": "0x7521EDa00E2Ce05aC4a9d8353d096CCB970d5188",
  "amount": "100",
  "gasStation": "0",
  "slippage": 0.01
}

Response Example

{
  "success": true,
  "data": [
    {
      "name": "Wanchain XFlows + XPort",
      "success": true,
      "data": {
        "amountOut": 99.684212,
        "extraInfo": {
          "path": [
            [
              "0x11e77E27Af5539872efEd10abaA0b408cfd9fBBD",
              "0xdabD997aE5E4799BE47d6E69D9431615CBa28f48",
              "0x52A9CEA01c4CBDd669883e41758B8eB8e8E2B34b"
            ],
            [
              500,
              500
            ]
          ],
          "amountOut": "100044371",
          "mode": "CrossSwap",
          "params": {
            "fromChain": "0x80002328",
            "toChain": "0x40000002",
            "fromToken": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
            "refundAddress": "0x7521EDa00E2Ce05aC4a9d8353d096CCB970d5188",
            "fromAmount": "100000000",
            "toAddress": "0x7521EDa00E2Ce05aC4a9d8353d096CCB970d5188",
            "amountOutMin": "98687370",
            "wrappedFromToken": "0x11e77e27af5539872efed10abaa0b408cfd9fbbd",
            "wrappedToToken": "0x52a9cea01c4cbdd669883e41758b8eb8e8e2b34b",
            "smgID": "0x000000000000000000000000000000000000000000000041726965735f303532",
            "tokenPairID0": "233",
            "networkFee0": "0",
            "serviceFee0": "180000",
            "crossType0": 0,
            "tokenPairID1": "449",
            "crossType1": 1,
            "messageFee": "13460135000000",
            "gasStation": "0",
            "swapFee0": 500,
            "swapFee1": 500
          },
          "fees": {
            "networkFee0": "0",
            "networkFee1": "54000000000000000",
            "serviceFee0": "180000",
            "serviceFee1": "360159",
            "discount": "900000000000000000"
          }
        },
        "tx": {
          "value": "13460135000000",
          "to": "0xAeCbF30602caF42467e7120C04271EDcC843f3c7",
          "data": "0x4bcb403a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000008000232800000000000000000000000000000000000000000000000000000000400000020000000000000000000000009702230a8ea53601f5cd2dc00fdbc13d4df4a8c70000000000000000000000007521eda00e2ce05ac4a9d8353d096ccb970d51880000000000000000000000000000000000000000000000000000000005f5e10000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000005e1d98a00000000000000000000000011e77e27af5539872efed10abaa0b408cfd9fbbd00000000000000000000000052a9cea01c4cbdd669883e41758b8eb8e8e2b34b000000000000000000000000000000000000000000000041726965735f30353200000000000000000000000000000000000000000000000000000000000000e90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bf20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c1000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000c3dee90b7c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000000147521eda00e2ce05ac4a9d8353d096ccb970d5188000000000000000000000000"
        }
      }
    },
    {
      "name": "Risk Detect",
      "success": true,
      "isRisk": false
    }
  ],
  "id": 1742287332481
}

You can use the tx data from the response to initiate a transaction on the source chain by calling the smart contract to complete the transaction. Please note that if you're dealing with an ERC20 Token, you need to approve the 'to' address beforehand.

Additional technical note: For ERC20 tokens, you must call the approve() function on the token contract to authorize the smart contract to spend your tokens before executing the main transaction. This is a standard security measure in the ERC20 token standard.

Example flow:

  1. First approve: token.approve(tx.to, amount)

  2. Then execute the main transaction with the provided tx data

Last updated