> For the complete documentation index, see [llms.txt](https://docs.wanchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wanchain.org/developers/xflows-api-old/1.4-examples.md). Agents can also search and read this documentation through its [MCP server](https://docs.wanchain.org/~gitbook/mcp).

# 1.4 Examples

#### Request Example

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

```

#### Response Example

```json
{
  "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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.wanchain.org/developers/xflows-api-old/1.4-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
