Skip to the article
Blocktide

Crypto markets, chains and policy

DEX token approval: why it comes before a swap

Why does a DEX need token approval before a swap? Its router needs an ERC-20 allowance to pull your tokens, and approval is a separate on-chain step.

By The Blocktide Editors4 min read

DEX token approval: why it comes before a swap

A DEX token approval lets the exchange’s router move your tokens into a swap, so you can complete the trade after the permission is confirmed. For the ShibaSwap example, shiba swap is where that two-step process becomes practical: approve SHIB for the router, then sign the swap. ERC-20 tokens use an allowance to let a contract spend up to a set amount on the holder’s behalf; without enough allowance, the router cannot pull the tokens.

What does token approval allow?

An ERC-20 approval gives a specific spender permission to transfer a limited amount of a specific token from your wallet. The token stays in your wallet until a transaction uses that permission. Approval changes the allowance recorded by the token contract; it does not itself exchange, deposit, or move the tokens.

The standard separates three jobs:

  • approve sets how much a spender may use.
  • allowance reports how much permission remains.
  • transferFrom lets the approved spender move tokens within that allowance.

The EIP-20 token standard defines these functions. In a typical DEX swap, the router calls transferFrom to take the input tokens from your wallet and execute the trade. That call works only if the token contract recognizes the router as an approved spender and the allowance covers the amount. The ethereum.org ERC-20 explanation describes the same approve-and-transfer pattern for sending tokens to contracts.

This is different from a wallet connection. Connecting MetaMask lets a site request transactions and show your address; it does not, by itself, grant a smart contract permission to spend a token. Approval is the on-chain permission the token contract checks when the router tries to pull funds.

Why is approval a separate transaction?

The token contract and the DEX router have separate roles, so permission must be recorded before the router can use it. The approval transaction calls the token’s approve function and updates the allowance. The later swap transaction calls the DEX and uses the allowance to move the input tokens.

That separation changes what you should expect from your wallet. An approval prompt is not the swap prompt, and approving does not mean the trade has happened. Each on-chain transaction needs its own signature and can cost gas. On Ethereum, the approval has its own gas cost; the swap also needs gas when you sign it.

Some interfaces ask for approval only up to the amount needed for the trade. Others may request a larger or unlimited allowance, which can avoid repeating approval for later swaps with the same spender. The trade-off is convenience against the amount that contract is authorized to pull. Read the amount and spender in MetaMask before confirming, and grant only what you are comfortable authorizing.

What should you do after approving SHIB?

When swapping SHIB, approve the token for the router shown by the DEX, wait for that approval transaction to confirm, then return to the swap screen and sign the swap itself. The approval is the permission step; the swap is the transaction that attempts to trade your tokens.

For example, you select SHIB and another token, enter an amount, and the interface first asks for approval. After you confirm that prompt, MetaMask may show the approval as pending while the network processes it. Once confirmed, the interface should let you proceed. Review the next prompt as a separate transaction: check the token amounts, network, and destination details before signing.

If the approval confirms but the swap does not follow, return to the DEX and submit the swap. A confirmed allowance does not automatically send a second transaction. If the approval remains pending, wait for the network or inspect its status in Etherscan before deciding what to do next.

Does approval carry over to another network?

An approval covers one token contract, one spender address, and one network. It is not a general permission attached to your wallet. So approving SHIB for a router on Ethereum does not approve a token or router on Shibarium; a fresh prompt on the other network is expected.

That boundary matters when comparing a repeat swap with a move to another chain. On the same network, an existing allowance may cover another swap with the same router, depending on how much remains. On a different network, the contracts and allowance are separate. Check that MetaMask is on the network you intend to use before approving, and make sure the prompt names the expected token and spender.

To review permissions later, Etherscan’s Token Approval Checker shows token approvals by spender for the network you select. Use it to inspect or revoke an allowance you no longer want; disconnecting a site from MetaMask does not change an on-chain approval. If the approval prompt is confirmed, return to the swap screen and sign the swap only after checking its details.