Take a look under the hood to see how a transaction is executed through 0x Protocol.
May 4, 2023
Learn & Build

0x Protocol is the trusted open source protocol for the settlement of decentralized exchange of tokenized value. It is the foundational settlement layer of the 0x infrastructure tech stack and a core Web3 building block. 0x Protocol reliably executes orders created by off-chain services such as 0x’s Swap API in a non-custodial manner.
In this article, we take a look under the hood to see how a transaction is executed through 0x Protocol.
For any given trade, there are two actors participating in the transaction: the “Maker”, short for market maker, and the “Taker”, the actor who wants to take the order the Maker is making. A trade between these two parties happens via an order.
For a transaction to be executed through 0x Protocol, a 0x order is required. A 0x order is a message passed through 0x Protocol to facilitate the trade of an ERC20 token for an ERC20, ERC721, or ERC1155 token.
What exactly is an order? An order is a packet of data that contains the order’s details, such as what assets are being traded, the Maker’s and Taker’s addresses, and at least one valid signature. When two entities agree on the terms of a trade, the 0x order is submitted to the respective blockchain and settled via 0x Protocol smart contracts.
The 0x Protocol supports different order types, including Limit Orders, whose structure is shown below:

There are currently three types of orders in 0x Protocol:
Let’s take a look at the illustration below to see how a 0x order works. This flow applies to ERC20 to ERC20 trades and ERC20 to NFT trades.

Unlike other decentralized exchanges that function entirely on-chain, 0x does not store orders on the blockchain; instead, orders are stored off-chain and only trade settlement occurs on-chain. This unique feature of off-chain relay, on-chain settlement makes 0x highly flexible and gas-efficient because only settlement information needs to be stored on-chain.
In this article, we discussed the structure of 0x Orders, how they encode trade details between a Maker and Taker, and how orders are shared and swapped via the “off-chain relay, on-chain settlement” paradigm.
0x offers a suite of fully integrated APIs to help you easily tap into this trading liquidity. Check out our guide below to learn how to get started building with Swap API:

Contents
Subscribe to newsletter