What Is Permit2?
Permit2 is a token approval management contract introduced by Uniswap Labs. It serves as a universal standard for off-chain token approvals and works with any ERC-20 token, even those that do not natively support EIP-2612 permit() functionality.
In simple terms, Permit2 allows users to authorize token spending through a signed message (off-chain) rather than performing an on-chain approval transaction, reducing gas usage and improving the user experience.
General Workflow
1. User Signs an Approval Message
Instead of calling token.approve(spender, amount) on-chain, the user signs an EIP-712 structured message off-chain. This signed message contains the token, spender, amount, and expiration data.
This step is gas-free because it does not require an on-chain transaction.
2. The dApp Submits the Signature
When the user executes a swap or similar transaction, the DApp includes the signed Permit2 message in the transaction request body, for example:
{
"permit2Signature": "0x..."
}
The protocol then forwards the signature to the Permit2 contract during execution. Permit2 validates the signature and grants a temporary, scoped allowance for the transaction.
3. Token Transfer Occurs in One Transaction
Permit2 validates the signature and transfers tokens atomically, meaning approval and transfer happen in a single transaction. There are no leftover approvals or permanent allowances unless explicitly configured.
Advantages of Permit2
One-Time Approvals Across Protocols
Users can approve a spender once and use that approval across multiple protocols that integrate Permit2. This eliminates repetitive approvals and additional approval transactions.
Enhanced Security
Permit2 avoids the use of infinite token approvals and instead enables:
- Expiring or limited-use approvals
- Nonce-based control for replay protection
- Scoped allowances per protocol or action
Gas Efficiency
Approvals are handled off-chain via signatures, reducing gas costs and consolidating approval and swap into a single transaction.
Standardization
Unlike older systems that rely on token-level support, Permit2 provides a universal interface that works with any ERC-20 token, making it a standard solution for modern DeFi protocols.
How Odos Uses Permit2
Within the Odos Smart Order Router (SOR), if a token requires approval, Odos can include a permit2Message in the quote response.
Developers can then:
- Sign the message locally using the user's private key or wallet.
- Attach the resulting
permit2Signatureto the/sor/assemblerequest. - Execute the swap in one transaction.
This eliminates the need for a separate approve() transaction and ensures that the swap executes efficiently and securely.