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.