Wanchain - We Are All Connected!
WebsiteBridgeExplorerEcosystem
  • 👋 Welcome to Wanchain
  • Products
    • WanBridge
      • Bridge-to-Earn
      • XP
    • XFlows
      • XP
    • XPort
      • XPort developer handbook
      • Supported chains
    • XStake
  • Cross-Chain Infrastructure
    • Wanchain Bridge Node Group
    • Wanchain L1 blockchain
      • Network information
    • WAN coin
      • How to get WAN coins
      • WAN coin faucets
      • xWAN
  • The Convert n' Burn System
    • Overview
    • Bridge fees
      • Conversion and distribution
    • Discounts
  • Developers
    • WanBridge API
      • 1. Information Retrieval
        • 1.1 Supported Chains and Tokense 1
        • 1.2 Cross-chain Quota and Fees
        • 1.3 Asset Lock Address
        • 1.4 Storeman Group ID (smgID)
      • 2. Creating Cross-chain Transactions for WanBridge
        • 2.1 Direct Interaction with On-chain Contracts
        • 2.2 Creating Cross-Chain Transactions Using API
      • 3. Circle CCTP Cross-Chain
        • 3.1 EVM Compatible Chains
      • 4. Status Query
    • XFlows API
      • 1.1 Basic Information
      • 1.2 Request Parameters
      • 1.3 Response Parameters
      • 1.4 Examples
      • 1.5 Notes
      • 1.6 Status Query
    • XPort Developer Handbook
  • PoS Validator Nodes
    • Important Terms and Parameter
    • Recommended Hardware & Software
    • Mainnet Node Setup (Quick Start)
    • Mainnet Node Setup (Manually)
    • Getting Started With AWS
    • Common Operations (CLI)
    • Delegation Guide
    • Commonly Used Scripts
    • GWAN PoS API
    • Partner Model Staking Guide
    • Staking FAQ
  • Wanchain Bridge Nodes
    • Fact Sheet
    • How to deploy a Bridge Node
  • External Links
    • Blog
    • Email
    • GitHub
    • Telegram
    • Telegram Tech Support
    • Twitter/X
    • WanBridge
    • XFlows
    • XStake
    • WanScan
    • Website
Powered by GitBook
On this page
  1. Developers
  2. XFlows API

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

Previous1.3 Response ParametersNext1.5 Notes

Last updated 1 day ago