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. GASLESS TRADES

Obtaining gasless quotes

This document provides a step-by-step guide on how to retrieve gasless quotes using the quote single endpoint in the ZCX API.

What is a gasless trade?

A gasless trade is a transaction where the user does not directly pay for the gas fees (the computational cost of executing a transaction on a blockchain). Instead, these fees are typically covered by a third party (us) to enhance the user experience. The user doesn't need native to pay the gas!

How to Enable Gasless Trades

To perform gasless trades, you can use the same quote endpoint as regular trades, with two additional parameters to enable the gasless feature:

Required Parameters

  • version=v2: This specifies the use of the second version of our smart contract, which introduces the gasless trading feature. This version also supports additional enhancements such as:

    • Permit2 for streamlined approvals.

    • The ability to specify a feeReceiver.

    • Other advanced functionalities.

  • isGasless=true: This explicitly requests a gasless quote where Unizen will cover the gas fees.


How Gasless Quotes Work

  • When you request a gasless quote, Unizen pays the gas fees on behalf of the user.

  • To offset the gas cost, the returned quote amount is slightly reduced by an amount equivalent to the gas cost.

  • The quote response structure remains identical to that of regular trades, so no changes are needed to parse or handle the quote.


Steps to Conduct a Gasless Trade

  1. Get a Gasless Quote:

    • Use the quote endpoint with the additional parameters:

      GET /quote?version=v2&isGasless=true&...otherParameters
    • The response will include the same fields as regular quotes.

  2. Generate typed data for sign gasless trade: Use the transactionData from step 1 to create the typed data needed for confirming and signing a gasless order. Important: this endpoint returns an updated transactionData. This new data is the one to be used to submit the trade.

  3. Optional Step: Call the estimateGas endpoint to simulate the transaction and determine whether it will succeed or fail.

  4. Submit the Trade:

  • To execute the trade, you must call the Create Order endpoint and provide the required trade details.

  • Important: use the transactionData (call field) returned by the typed-data endpoint, not the one obtained in the quote endpoint.

  • Our system processes the order and conducts the trade on behalf of the user.


Benefits of Gasless Trades

  • No Gas Fees for Users: Users do not need to pay gas fees or hold native tokens for the transaction.

  • Streamlined Integration: The same quote structure and swap flow as regular trades make integration straightforward.

  • Simplified User Experience: Reduces friction for users, especially those new to blockchain transactions.


Additional Notes

  • Ensure the version=v2 parameter is included, as gasless trades are only supported in the second version of our smart contracts.

  • Gasless trades is enabled only for single chain trades, for now.

  • The reduced quote amount accounts for the gas costs covered by Unizen.

By following these steps, you can seamlessly integrate gasless trading into your workflow. Let us know if further assistance is needed! 🚀

PreviousError MessagesNextGas estimation

Last updated 1 month ago

Was this helpful?