All Articles
All Articles

What is Permit2? – Contract Guide + How to Revoke

Table of Contents

A smart contract originally conceived by Uniswap, Permit2 manages the approval of token transfers via gasless signatures. If you are curious about what this is and what this means for the security of your assets. This article will explore the benefits of Permit2 and how it impacts token approvals within the DeFi space, especially on platforms like Uniswap.

What Is Permit2?

Permit2 is a smart contract created for simplifying ERC-20 token approvals. Normally, people must carry out numerous approval transactions for every DeFi interaction. This process can be troublesome and expensive (depending on gas fees.

The problem above finds its solution in Permit2, which works by giving users the power to offer authorization once only to the Permit2 contract itself. This Permit2 approval allows the contract to handle sub-approvals for other contracts. Permit2 acts like a ‘proxy,’ and it can enhance the user experience of DeFi together.

permit2 infographic

Uniswap‘s Permit2 infographic from the official announcement blog

The Permit2 approval flow makes things easier for users. It helps to save time and gas fees by lessening the requirement for multiple approval transactions. In this way, Permit2 boosts the user experience by delivering a smoother method of interaction. Also, it mitigates security hazards tied to several transaction approvals. The Permit2 contract also includes extra security features. These involve approvals that have an expiry date which stops permissions from staying too long and being utilized improperly.

Permit2 is widely available. The contract is deployed across most EVM blockchains such as Ethereum, Optimism, Arbitrum, Polygon, and Base. This provides compatibility and safety in many applications.

History of Permit2

Permit2 was launched by Uniswap Labs in November 2022. It marked a step to improve the safety and speed of token approvals. The advantages of Permit2 integration quickly spread throughout the DeFi industry. Dapps used the functions provided by the Permit2 contract to make transactions easier, safer, and less costly for users. The wide adoption of Permit2 in these protocols highlights its usefulness and Uniswap’s sway over the industry.

For developers and users who want to know about the function and benefits of this system; they can find the Permit2 contract address and integration details in a guide provided by Uniswap. This thorough review covers how the Permit2 approval method works in real-life situations, improving token handling within different applications. By meeting demands from the DeFi community, Permit2 sets up a fresh norm for safe and swift token approvals.

How Permit2 Works Technically

Features of Permit2

  • Approvals Based on Signature: Any ERC-20 token can utilize permit-style approvals with Permit2, even if they don’t support EIP-2612 – this advancement makes a single transaction flow possible for applications. It combines a license signature with transaction details, making everything easier and lowering expenses.
  • Batched Token Approvals: One can arrange authorizations for different tokens to various spenders in one action, boosting the handling of multiple token interactions.
  • Signature-Based Token Transfers: This feature does away with the requirement of setting allowances for token transfers. Users can move tokens straight to spenders using a signed message. In this manner, they guarantee that permissions are only for a limited time and linked closely to the transaction’s time frame.
  • Safe Arbitrary Data Verification: Permit2 confirms the safety of extra data by comparing it with a witness hash and type, following EIP-712 standard. This action strengthens the transaction’s completeness.
  • Signature Verification for Contracts: Permit2, which supports EIP-1271, allows a contract to verify signatures and approve token transfers or approvals through signed messages. This broadens the use of Permit2 in many different contract interactions.
  • Non-Monotonic Replay Protection: This embraces the concept of non-sequential nonces in signature-based transfers, which eliminates the necessity for transactions to take place in a particular order.
  • Expiring Approvals: Permit2 introduces time-bound approvals. These naturally expire, thus reducing the risk associated with permanent approvals and eliminating the need for manual revocation.
  • Batched Token Transfers and Revokes: Users can execute transfers of multiple tokens or revoke allowances in a single transaction, significantly reducing gas costs and transaction complexity.

Architecture and Integration

Permit2 is made up of two important parts: the AllowanceTransfer and SignatureTransfer contracts.

The AllowanceTransfer contract handles token allowances, managing certain permissions for spenders. Meanwhile, the SignatureTransfer contract helps with all signature-based transfers, skipping usual allowance methods to make it more safe and efficient.

For Permit2 to combine with external contracts it needs to get user confirmation for the Permit2 contract through the related token contract. This initial permission allows Permit2 to manage sub-permissions in a well-organized and safe manner.

Technical Deployment

Permit2 uses viaIR compilation for better deployment and integration in its applications. To incorporate Permit2, developers need to be ready for the technical prerequisites this method requires. They might also consider using the DeployPermit2 utility in their testing environments before production.

Security and Community Engagement

Permit2 is included in the Bug Bounty initiative of Uniswap Labs. This program incentivizes involvement from the community to spot and fix any existing or new security risks. Such cooperative methods guarantee that Permit2 stays strong against developing risks and continues as a cornerstone for securing DeFi applications.

Risks of Permit2

One of the key selling points of Permit2 is also its biggest risk. On one hand, Permit2 simplifies token approvals. By allowing for batching of approvals, it also introduces complexity into contract code on the other hand – this makes it altogether less transparent too: phishing websites might take advantage of this complexity, deceiving users into granting permissions they do not fully understand. Consequently, this can lead to loss of funds.

permit2 risks

Thread breaking down Permit2 risks

For developers, implementing Permit2 can bring challenges. Incorporating Permit2 is more complex than regular token approvals or EIP2612 permit signatures – though this investment in time and resources may be warranted by the universal token support and improved security features that Permit2 offers, it still nonetheless represents a hurdle – especially for smaller teams or those with fewer resources. The additional work needed may disincentivize developers, slowing down Permit2’s acceptance in dapps for the end-user.

Analyzing for Permit2 Risks With De.Fi Scanner

Users can use the De.Fi Scanner to analyze Permit2 permissions. De.Fi Scanner is an all-in-one smart contract auditing tool, that allows you to audit any smart contract or token address in just a few seconds. Simply enter the contract address in the search bar, and you will be given a comprehensive scan of the contract, informing you of the security risks present.

brett on base scanner analysis

BRETT on Base Scanner Analysis

De.Fi Scanner is the perfect tool to evaluate which contracts may utilize Permit2 approvals and to understand the specific permissions associated.

On top of this, our De.Fi Shield tool allows you to detect risky approvals. Should you have exposure to a dangerous Permit2 approval, you can discover it and revoke it near-instantly.

defi shield

Analyze your permissions with De.Fi Shield

It does this by automatically scanning your wallet and grouping contracts you have approved by risk level, ranging from high risk to informational. Simply hit the ‘revoke’ button and approve the transaction to revoke contract access.

Enhance Your Web3 Safety With De.Fi

De.Fi SuperApp including tools like Scanner and Shield, along with other advanced instruments like the De.Fi AI Score and our CoinMarketCap of Security, help you remain alert towards risks in this rapidly developing ecosystem.

defi market security page

Our market-wide security analysis page

For updates in real time, check out the rest of our blog or visit our X profile. These resources are designed to help both new and skilled investors safely participate in web3.

More from De.Fi Security

Is Rabby Wallet Safe? - DeFi Wallet Review

On that front, DeFi wallets are in high demand and Rabby Wallet is an option that's quickly gaining mindshare. But the fact of the matter is, Rabby is only one in a sea of wallet providers. Users must carefully weigh their options to know whether or not it's the right choice.

Is Rainbow Wallet Safe? - Crypto Wallet Review

In the rapidly expanding universe of web3 and decentralized finance (DeFi), selecting a reliable and secure wallet is crucial. Rainbow Wallet has emerged as a popular choice, especially for those new to the crypto world. 

© De.Fi. All rights reserved.