Skip to main content
Before executing a transfer with an ERC20 token, you must approve the LI.FI contract to spend tokens on behalf of the user. This page explains when approval is needed and how to handle it correctly.

When Is Approval Needed?

Decision Logic


Step 1: Identify the Spender

The spender address comes from the quote response:
Always use estimate.approvalAddress from the quote response. Never hardcode spender addresses - they may vary by route or bridge.

Step 2: Check Current Allowance

Call the allowance function on the token contract:

Function Signature

JavaScript Example

Python Example


Step 3: Compare and Decide


Step 4: Send Approval Transaction

Function Signature

Approval Amount Strategies

For AI agents, exact approval is recommended for security. For user-facing apps, consider letting users choose.

JavaScript Example

Python Example


Complete Approval Flow


Common Mistakes

Always use quote.estimate.approvalAddress, not a hardcoded address. Different routes may use different contracts.
The main transaction will fail if sent before the approval is confirmed. Always wait for the approval receipt.
Ensure your wallet is connected to the source chain (fromChain) when sending the approval.
Approval transactions typically need 50,000-100,000 gas. Use a reasonable gas limit.
USDT requires setting allowance to 0 before setting a new non-zero value. Check current allowance and reset if needed.

Approval Checklist

Before executing a transfer, verify:
  • fromToken.address is NOT 0x0000...0000 (native token)
  • Retrieved approvalAddress from quote response
  • Checked current allowance(owner, spender)
  • Compared allowance to fromAmount
  • Sent approval tx if allowance < fromAmount
  • Waited for approval confirmation
  • Connected to correct chain (fromChain)