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.

  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.

  • 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.

  • 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! 🚀

Last updated