Book a free call

Web3 Exchange Architecture: How the Pieces Fit Together

A Web3 exchange is a matching engine, wallets, custody, liquidity and compliance wired together. Here is how each layer works and what to build first.

Hertiv engineering teamReviewed by a senior engineer
7 min read
Web3 Exchange Architecture: How the Pieces Fit Together
On this page

Short answer

Web3 exchange architecture is the design of a trading platform that lets users buy and sell crypto assets, built from a matching engine, an order book, wallets and custody, liquidity sources, settlement, and compliance checks. The architecture splits into three layers: the trading core that matches orders, the asset layer that holds and moves funds, and the control layer that handles identity, risk and reporting.

What is the architecture of a Web3 exchange?

A Web3 exchange is a trading platform for crypto assets, and its architecture is the way its parts are arranged. At the centre sits the matching engine, which pairs buy and sell orders. Around it sit the order book, the wallets that hold user funds, the custody system that protects them, the liquidity that fills orders, and the compliance checks that decide who can trade.

The key difference from a traditional exchange is the asset layer. In a Web2 exchange, balances are rows in a database. In a Web3 exchange, balances are tokens on a chain, and moving them means signing a transaction. That makes wallets, keys and settlement part of the core design, not an afterthought.

There are two broad shapes. A centralised exchange holds user funds in its own wallets and matches orders off-chain, which is fast but means users trust the operator. A decentralised exchange matches orders with smart contracts and lets users keep their own keys, which is slower per trade but removes the custodian. Many products mix the two: off-chain matching with on-chain settlement.

What are the layers of a Web3 exchange?

A Web3 exchange has five layers, and each one can be built, bought or borrowed separately. The layers below are in the order a trade passes through them.

LayerWhat it doesKey choices
Trading coreMatches buy and sell ordersMatching engine speed, order types, fee model
Order bookHolds open orders and market depthOn-chain or off-chain book, market makers
Asset layerHolds and moves fundsHot and cold wallets, custody, multi-signature
LiquidityFills orders at fair pricesMarket makers, liquidity pools, external venues
Control layerIdentity, risk and reportingKYC and AML checks, limits, audit trails

The trading core is the part users feel: if matching is slow, the exchange feels slow. The asset layer is the part that decides whether funds are safe: if custody is weak, nothing else matters. The control layer is the part regulators ask about: if identity checks are missing, the exchange cannot operate in most markets. For the development side of the build, crypto exchange development covers the full scope.

How does the trading core work?

The trading core has two parts: the matching engine and the order book. The order book is the list of open buy and sell orders at each price, and the matching engine pairs them. When a buy order at $100 meets a sell order at $100, the engine records a trade at that price and updates both balances.

Speed matters because traders compare exchanges by how fast their orders fill. A centralised exchange matches orders off-chain, in memory, which can handle thousands of orders a second. A decentralised exchange matches orders with smart contracts, which is slower and costs gas for each step, so many decentralised exchanges match off-chain and settle on-chain instead.

Order types are the second decision. Market orders fill at the best available price; limit orders wait for a chosen price; stop orders trigger when a price is reached. Supporting more order types attracts more traders, but each type adds logic to the matching engine and more cases to test. A first version usually ships market and limit orders, then adds the rest.

How do wallets, custody and settlement work?

Wallets hold the funds, custody protects them, and settlement moves them. Most exchanges split wallets into hot and cold: hot wallets hold the small share needed for daily withdrawals and are connected to the network, while cold wallets hold the bulk offline. The split limits what an attacker can reach in one breach.

Custody decides who controls the keys. A centralised exchange holds the keys itself, often with multi-signature wallets that need several approvals to move funds. A decentralised exchange leaves keys with the user, and the smart contract moves funds only when the trade conditions are met. Some exchanges use a third-party custodian, which adds a layer of separation between the trading company and the funds.

Settlement is the step that makes a trade final. On a centralised exchange, settlement is an internal ledger update, which is instant. On a decentralised exchange, settlement is an on-chain transaction, which takes as long as the chain takes and costs gas. That is why many decentralised exchanges batch settlements: many trades settle in one on-chain transaction, which cuts cost and delay. For the wallet side, crypto wallet development covers hot, cold and multi-signature design.

Where does liquidity come from?

Liquidity is the ability to fill an order at a fair price without moving the market, and a new exchange has none on day one. There are three sources: market makers, liquidity pools and external venues.

Market makers are firms that quote buy and sell prices all day in exchange for fees or rebates. Liquidity pools are smart contracts where users deposit pairs of tokens and traders swap against them. External venues are other exchanges whose order books can be reached through an aggregator.

Most new exchanges start with market makers, because they bring depth from day one. The cost is a commercial agreement and sometimes a loan of tokens for quoting. Liquidity pools suit decentralised exchanges, because they need no agreement — anyone can deposit tokens — but the depth depends on how much is deposited, and thin pools mean wide spreads.

The risk is relying on one source. If a single market maker stops quoting, the book empties and traders leave. A sound design uses at least two sources and monitors depth continuously, so a thin book is noticed before users do.

Example (hypothetical): a first-version exchange for one token pair

Example (hypothetical): a team builds a first version of a centralised exchange for one token pair, with off-chain matching and on-chain settlement. The build budget is $300,000 and the team is six people for nine months. The scope is market and limit orders, hot and cold wallets, one market maker, and identity checks.

The arithmetic is straightforward. The team expects 500 active traders in the first year, each trading $2,000 a month on average, which is $1,000,000 of monthly volume. At a 0.2% trading fee, that is $2,000 a month in fee income, or $24,000 in the first year. Running costs are $12,000 a month for hosting, market making and compliance, or $144,000 a year.

The gap is the point of the example: fee income of $24,000 against running costs of $144,000 leaves a $120,000 shortfall in year one, before the $300,000 build cost. The exchange only works if volume grows, which is why liquidity and trader acquisition matter more than extra order types in the first year.

Common mistakes in Web3 exchange architecture

The most common mistake is building the matching engine before the custody design. Teams love the trading core because it is the visible product, but custody is where funds are lost. A matching engine can be rebuilt; stolen funds cannot be recovered. Design custody first, then matching.

Another mistake is launching with one liquidity source. A single market maker or a single pool leaves the exchange exposed the day that source stops. Two sources and a depth monitor are the minimum, not a luxury.

Finally, do not treat compliance as a later phase. Identity checks, transaction monitoring and audit trails shape the data model: if the system was not built to record who traded what and when, adding that history later means rebuilding the ledger. Build the audit trail into the first version, even if the checks themselves are simple at first. For the compliance side, DeFi development covers the wider regulatory picture.

What to do next

Start with three decisions: centralised or decentralised, which chain or chains, and which token pairs to list first. Those three answers shape the matching engine, the custody design and the liquidity plan.

Then scope the first version to market and limit orders, hot and cold wallets, one market maker, and identity checks with an audit trail. Prove that a trade can be matched, settled and audited end to end before adding order types, pairs or chains.

Key takeaways

  • A Web3 exchange has five layers: trading core, order book, asset layer, liquidity and control.
  • The matching engine pairs orders; the asset layer holds and moves funds; the control layer handles identity and risk.
  • Hot wallets hold daily funds; the bulk sits in cold storage with multi-signature approvals.
  • New exchanges need at least two liquidity sources, or the book empties when one stops.
  • Design custody and the audit trail first; the matching engine can be rebuilt, stolen funds cannot.

Frequently asked questions

What is a Web3 exchange?

A Web3 exchange is a trading platform for crypto assets, built from a matching engine, an order book, wallets and custody, liquidity sources, settlement, and compliance checks. It lets users buy and sell tokens, with balances held as tokens on a chain rather than rows in a database.

What is the difference between a centralised and a decentralised exchange?

A centralised exchange holds user funds in its own wallets and matches orders off-chain, which is fast but means users trust the operator. A decentralised exchange matches orders with smart contracts and lets users keep their own keys, which removes the custodian but is slower per trade.

What is a matching engine?

A matching engine is the part of an exchange that pairs buy and sell orders. When a buy order at a price meets a sell order at the same price, the engine records a trade at that price and updates both balances.

What are hot and cold wallets?

Hot wallets are connected to the network and hold the small share of funds needed for daily withdrawals. Cold wallets are offline and hold the bulk of funds, which limits what an attacker can reach in one breach.

Where does a new exchange get liquidity?

From market makers that quote prices all day, from liquidity pools where users deposit token pairs, or from external venues reached through an aggregator. Most new exchanges start with market makers and add a second source as soon as they can.

How much does it cost to build a Web3 exchange?

A first version for one or two pairs typically costs $250,000 to $500,000 to build, with running costs for hosting, market making and compliance on top. These are indicative ranges for a small team, not vendor quotes.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a Web3 exchange? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Crypto Exchange service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call