🔑🔑🔑 next generation token approvals mechanism
Solidity
948
184 commits
updated Aug 19, 2024
Permit2 introduces a low-overhead, next-generation token approval/meta-tx system to make token approvals easier, more secure, and more consistent across applications.
Permit2 integrated contracts.Permit2 is the union of two contracts: AllowanceTransfer and SignatureTransfer.
The SignatureTransfer contract handles all signature-based transfers, meaning that an allowance on the token is bypassed and permissions to the spender only last for the duration of the transaction that the one-time signature is spent.
The AllowanceTransfer contract handles setting allowances on tokens, giving permissions to spenders on a specified amount for a specified duration of time. Any transfers that then happen through the AllowanceTransfer contract will only succeed if the proper permissions have been set.
Before integrating, contracts can request users’ tokens through Permit2, users must approve the Permit2 contract through the specific token contract. To see a detailed technical reference, visit the Uniswap documentation site.
Permit2 uses viaIR compilation, so importing and deploying it in an integration for tests will require the integrating repository to also use viaIR compilation. This is often quite slow, so can be avoided using the precompiled DeployPermit2 utility:
import {DeployPermit2} from "permit2/test/utils/DeployPermit2.sol";
contract MyTest is DeployPermit2 {
address permit2;
function setUp() public {
permit2 = deployPermit2();
}
}
This repository is subject to the Uniswap Labs Bug Bounty program, per the terms defined here.
You will need a copy of Foundry installed before proceeding. See the installation guide for details.
git clone https://github.com/Uniswap/permit2.git
cd permit2
forge install
forge fmt [--check]
# unit
forge test
# integration
source .env
FOUNDRY_PROFILE=integration forge test
forge snapshot
Run the command below. Remove --broadcast, ---rpc-url, --private-key and --verify options to test locally
forge script --broadcast --rpc-url <RPC-URL> --private-key <PRIVATE_KEY> --verify script/DeployPermit2.s.sol:DeployPermit2
Inspired by merklejerk's permit-everywhere contracts which introduce permit based approvals for all tokens regardless of EIP2612 support.
98 followers · starred Nov 2025
1,974 followers · starred Jun 2023
876 followers · starred Jan 2023
154 followers · starred Nov 2022
🔑🔑🔑 next generation token approvals mechanism
Solidity
948
184 commits
updated Aug 19, 2024
Permit2 introduces a low-overhead, next-generation token approval/meta-tx system to make token approvals easier, more secure, and more consistent across applications.
Permit2 integrated contracts.Permit2 is the union of two contracts: AllowanceTransfer and SignatureTransfer.
The SignatureTransfer contract handles all signature-based transfers, meaning that an allowance on the token is bypassed and permissions to the spender only last for the duration of the transaction that the one-time signature is spent.
The AllowanceTransfer contract handles setting allowances on tokens, giving permissions to spenders on a specified amount for a specified duration of time. Any transfers that then happen through the AllowanceTransfer contract will only succeed if the proper permissions have been set.
Before integrating, contracts can request users’ tokens through Permit2, users must approve the Permit2 contract through the specific token contract. To see a detailed technical reference, visit the Uniswap documentation site.
Permit2 uses viaIR compilation, so importing and deploying it in an integration for tests will require the integrating repository to also use viaIR compilation. This is often quite slow, so can be avoided using the precompiled DeployPermit2 utility:
import {DeployPermit2} from "permit2/test/utils/DeployPermit2.sol";
contract MyTest is DeployPermit2 {
address permit2;
function setUp() public {
permit2 = deployPermit2();
}
}
This repository is subject to the Uniswap Labs Bug Bounty program, per the terms defined here.
You will need a copy of Foundry installed before proceeding. See the installation guide for details.
git clone https://github.com/Uniswap/permit2.git
cd permit2
forge install
forge fmt [--check]
# unit
forge test
# integration
source .env
FOUNDRY_PROFILE=integration forge test
forge snapshot
Run the command below. Remove --broadcast, ---rpc-url, --private-key and --verify options to test locally
forge script --broadcast --rpc-url <RPC-URL> --private-key <PRIVATE_KEY> --verify script/DeployPermit2.s.sol:DeployPermit2
Inspired by merklejerk's permit-everywhere contracts which introduce permit based approvals for all tokens regardless of EIP2612 support.
98 followers · starred Nov 2025
1,974 followers · starred Jun 2023
876 followers · starred Jan 2023
154 followers · starred Nov 2022