LogoLogo
  • Introduction to Unizen
    • Unizen Overview
      • Unizen Liquidity Distribution Mechanism (ULDM)
        • ULDM Performance
      • Unizen Interoperability Protocol (UIP)
        • LayerZero
        • DeBridge
        • Stargate
        • Celer
        • Axelar
        • Thorchain
    • Unizen Dashboard
      • General
      • Portfolio
      • History
    • Unizen Trade
      • Fees
    • Unizen Explore
      • Unizen Omni-Chain Data Pool
    • Unizen Earn
  • ZCX
    • Token Utility
    • Tokenomics
  • API - Introduction
    • Introduction
    • Before you get started
      • Understanding Price Impact and Price Slippage in Token Swaps
      • Token Allowance Management for Non-updatable Allowance Tokens
      • Tokens with taxes
      • Wrapping and Unwrapping Native Tokens
      • Quote expiration deadline
    • Security Best Practices for Integrating Unizen
      • Why disable CORS
      • How to integrate with a reverse proxy
    • Version 2 of our smart contracts
      • Migration to smart contract v2
  • API - GET STARTED
    • QuickStart guide
    • Swagger
    • Information endpoints
      • GET /trade/v1/info/chains
      • GET /trade/v1/info/sources
      • GET/v1/info/cross-providers
      • GET /trade/v1/info/token/search
      • GET /v1/info/token/popular
      • GET /trade/v1/info/token/{chainId}/{tokenAddress}
      • GET /trade/v1/info/tokenLogo/{chainId}/{tokenAddress}
      • GET /info/thorchain-inbound-address
      • GET /trade/v1/info/tx/{txHash}
      • GET /trade/v1/info/trade/{chainId}/{txHash}
      • GET /trade/v1/info/trades
    • Approval
      • GET /trade/v1/{chainId}/approval/spender
      • GET /trade/v1/{chainId}/approval/transaction
      • GET /trade/v1/{chainId}/approval/allowance
    • Single-Chain Swap
      • GET /trade/v1/{chainId}/quote/single
      • GET /trade/v1/{chainId}/swap/single
      • Send transaction in evm chains
      • Send transaction in Solana
    • Cross-Chain Swap
      • GET /trade/v1/{chainId}/quote/cross
      • GET /trade/v1/{chainId}/swap/cross
      • Send transaction
    • Gasless orders
      • POST /trade/v1/gasless/typed-data
      • POST /v1/gasless/estimate
      • POST /v1/gasless/create
      • POST /v1/gasless/cancel
      • GET /trade/v1/gasless/status/{orderId}
      • GET /v1/gasless/orderByAddress/{address}
    • UTXO Assets and Cosmos Swap
      • GET /trade/v1/{chainId}/quote/cross 1
      • GET /trade/v1/{chainId}/swap/cross
      • Sending transactions
    • Efficient Quote Retrieval with Batch Processing
      • GET /trade/v1/{chainId}/batch_quote/single
    • Error Messages
  • GASLESS TRADES
    • Obtaining gasless quotes
    • Gas estimation
    • Executing the trade
    • Following the orders
  • On-Chain Contracts - Get Started
    • Integration with Unizen Contracts for Token Swapping
    • Registering Errors on Smart Contract Calls
  • PERMIT2
    • What is Permit2?
    • Usage in our api
  • WIDGET - Get Started
    • Embed the Unizen Widget
    • Playground
  • Other
    • Smart Contracts
    • Security Audits
    • Roadmap
  • links
    • Unizen
    • Marketing Website
    • Medium
    • Twitter
    • Discord
    • Telegram
Powered by GitBook
On this page

Was this helpful?

  1. API - GET STARTED

QuickStart guide

PreviousMigration to smart contract v2NextInformation endpoints

Last updated 7 months ago

Was this helpful?

  1. Sign Up: . Choose the plan or contact us to discuss about your needs.

  2. Fetch a Single-Chain Swap Quote: just a simple call to our api passing the api key as header.

curl -X 'GET' \
  'https://api.zcx.com/trade/v1/56/quote/single?fromTokenAddress=0x0000000000000000000000000000000000000000&toTokenAddress=0x55d398326f99059ff775485246999027b3197955&amount=10000000000000000000&sender=0x54c47034887C582Fc1Af4a9a3b68180a8a9eF2d2&receiver=0x54c47034887C582Fc1Af4a9a3b68180a8a9eF2d2&slippage=0.005&excludedDexes=%7B%0A%20%20%221%22%3A%20%5B%0A%20%20%20%20%220x0000000000000%22%0A%20%20%5D%0A%7D&priceImpactProtectionPercentage=0.5&slippageProtectionPercentage=0.5' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <YOUR API KEY>'
  1. The response is an array of quotes, choose the desired quote (the first is the best in terms of amount out) and take the transactionData and just a few fields and call the swap endpoint.

curl -X 'POST' \
  'https://api.zcx.com/trade/v1/56/swap/single' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <YOUR API KEY>' \
  -H 'Content-Type: application/json' \
  -d '{
  "transactionData": {
      "info": {
        "feePercent": 0,
        "sharePercent": 0,
        "srcToken": "0x0000000000000000000000000000000000000000",
        "dstToken": "0x55d398326f99059fF775485246999027B3197955",
        "deadline": 1728640582,
        "slippage": 0.005,
        "tokenHasTaxes": false,
        "path": [
          "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
          "0x55d398326f99059ff775485246999027b3197955"
        ],
        "v3Path": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00006455d398326f99059ff775485246999027b3197955",
        "tradeType": 0,
        "amountIn": "10000000000000000000",
        "amountOutMin": "5646899008721574387295",
        "actualQuote": "5675275385649823504819",
        "uuid": "UNIZEN-CLI",
        "apiId": "17",
        "userPSFee": 0
      },
      "call": [
        {
          "targetExchange": "0x13f4EA83D0bd40E75C8222255bc855a974568Dd4",
          "targetExchangeID": "pancakev3",
          "sellToken": "0x0000000000000000000000000000000000000000",
          "buyToken": "0x55d398326f99059fF775485246999027B3197955",
          "amountDelta": "5646899008721574387295",
          "amount": "10000000000000000000",
          "data": "0xb858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000880e0ce34f48c0cbc68bf3e745f17175ba8c650e0000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000001321e7759e10ae35e5f000000000000000000000000000000000000000000000000000000000000002bbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00006455d398326f99059ff775485246999027b3197955000000000000000000000000000000000000000000"
        }
      ]
    },
  "nativeValue": "10000000000000000000",
  "account": "0xF0Fbf42C54Ac40dA016003baD35E5AefaC6E1CE1",
  "receiver": "0xF0Fbf42C54Ac40dA016003baD35E5AefaC6E1CE1",
  "tradeType": 0
}'
  1. Finally in the response of this swap endpoint you have the data to conduct the trade on the user's wallet.

Check out our full API documentation in the next sections.

Request an API key