How Does the Approve Function Enable Decentralized Exchanges (DEXs)?

The approve function in ERC-20 allows a token holder to grant a third-party smart contract, like a DEX, permission to spend a specified amount of their tokens. When a user wants to trade, they first approve the DEX contract.

The DEX's trading function then calls transferFrom , moving the tokens from the user to the exchange's liquidity pool or another user. This is essential for non-custodial trading.

What Is the Difference between a Custodial and Non-Custodial Derivatives Exchange?
How Does the Concept of “Atomic Swap” Relate to DEX Trading?
How Do Transaction Speeds and Costs Compare on Custodial versus Non-Custodial Platforms?
How Do Gas Fees Compare between a Direct Transfer and an Approve() Transaction?
How Does Counterparty Risk Differ between Custodial and Non-Custodial Exchanges?
Explain the Difference between Custodial and Non-Custodial Collateral Management in Stablecoins
How Does a Token Allowance Differ from a Direct Token Transfer in a DeFi Transaction?
What Regulatory Differences Exist for Custodial and Non-Custodial Derivatives Exchanges?

Glossar