Permit2 and Gasless Transactions: How Signature Relay Works
Permit2 lets users approve token spending with a signature instead of an on-chain transaction. Here is how EIP-712 typed data, signature relay, and gasless approval work at the protocol level.
If you have ever swapped a token on Uniswap, you have probably used Permit2 without knowing it. The approval step that used to require a separate on-chain transaction, costing gas and adding a round trip, now happens through a signed message relayed by someone else. This article breaks down how that works at the protocol level, from EIP-712 typed data to the relayer model that makes gasless approval possible.
We will cover only public, open-source protocols. Permit2 is an open-source contract deployed by Uniswap Labs. EIP-712 is an Ethereum standard. The relayer pattern is a general technique used across the ecosystem. Nothing here is specific to any particular integrator.
The Problem Permit2 Solves
Before Permit2, token approvals worked through the standard ERC-20 approve function. A user calls approve(spender, amount) on the token contract. That call is an on-chain transaction. It costs gas. It requires the user to hold ETH for gas. And it is a separate transaction from the swap itself, meaning the user signs and broadcasts twice.
Some tokens implemented EIP-2612 permit, which allows approval via a signed off-chain message. That removed the gas cost and the extra transaction. But each token had to implement the standard individually, and many tokens never did. The result was a fragmented landscape where some tokens supported gasless approval and most did not.
Permit2 solves this by providing a single, universal approval layer that works with any ERC-20 token, regardless of whether the token itself implements EIP-2612. The user approves the Permit2 contract once. After that, all subsequent approvals to spenders are handled through off-chain signatures processed by Permit2.
How Permit2 Works at the Protocol Level
Permit2 is a singleton contract. It was deployed by Uniswap Labs and is open source, audited, and permissionless. Anyone can integrate it. The contract address is the same across chains where it is deployed.
The flow works in two layers.
First, the user does a single standard ERC-20 approve call, granting the Permit2 contract an allowance over their tokens. This is the only on-chain approval transaction the user ever needs to make for a given token. The allowance is typically set to the maximum uint256 value.
Second, for every subsequent spender, the user signs an off-chain message authorizing that spender to use their tokens through Permit2. The spender, or a relayer acting on the spender's behalf, submits that signature to Permit2's permit function. Permit2 verifies the signature, records the allowance internally, and the spender can now pull tokens via transferFrom.
The key insight is that the signature authorization is a gasless operation from the user's perspective. The user signs a message off-chain. Someone else pays the gas to submit it on-chain.
EIP-712 Typed Data: The Signature Foundation
Permit2 signatures use EIP-712, the Ethereum standard for typed structured data signing. EIP-712 exists because signing raw hashes is dangerous. If a user is asked to sign an opaque hex string, they cannot tell what they are authorizing. EIP-712 solves this by defining a structured, human-readable format that wallets can display to the user before they sign.
The EIP-712 standard defines two components.
The domain separator is a struct that binds a signature to a specific contract, chain, and application. It contains four fields: the name of the signing domain, the version, the chain ID, and the verifying contract address. This prevents signature replay across different contracts or chains. A signature valid for Permit2 on Ethereum mainnet is not valid for Permit2 on Polygon, because the chain ID differs.
The typed data is a struct definition specific to the operation being authorized. For Permit2, the PermitTransferFrom struct includes the token address, the amount, the nonce, and the expiration deadline. The wallet renders this as a structured display so the user sees exactly what they are signing.
Here is what the EIP-712 domain looks like in a generic integration:
struct EIP712Domain {
string name;
string version;
uint256 chainId;
address verifyingContract;
}
And here is the Permit2 PermitTransferFrom struct as defined in the public Permit2 contract:
struct PermitTransferFrom {
address token;
uint256 amount;
uint256 nonce;
uint256 deadline;
}
The signature is produced by hashing the domain separator and the typed data together, then signing the result with the user's private key. The wallet handles this. The developer's job is to construct the correct domain and message structs and present them to the wallet for signing.
The Permit2 Signature Flow, Step by Step
Let's walk through a generic Permit2 transfer authorization. This is the flow used by any application integrating Permit2.
Step 1. The application constructs a PermitTransferFrom struct containing the token address, the amount to transfer, a unique nonce, and a deadline timestamp.
Step 2. The application constructs the EIP-712 domain separator using the Permit2 contract address, the current chain ID, and the domain name and version strings ("Permit2" and "1" for the canonical deployment).
Step 3. The user's wallet is prompted to sign the typed data. The wallet displays the structured message. The user reviews it and signs. This produces an EIP-712 signature, typically 65 bytes in the r, s, v format.
Step 4. The signature, along with the permit struct and the spender address, is passed to Permit2's permitTransferFrom function. This call can be made by the spender directly or by a relayer.
Step 5. Permit2 verifies the signature using ecrecover. It checks that the nonce has not been used. It checks that the deadline has not passed. If all checks pass, Permit2 records the nonce as spent and transfers the tokens from the user's address to the recipient.
Step 6. The transfer is complete. The user never submitted an on-chain transaction. The user never paid gas for the approval.
Signature Relay: How Relayers Work
The relayer is the component that makes the transaction gasless from the user's perspective. A relayer is an off-chain service that takes the user's signature and submits it on-chain, paying the gas cost.
Here is the generic relayer flow.
The user signs a Permit2 message off-chain. The signature is sent to the relayer service, typically via an HTTP API. The relayer constructs the on-chain transaction, signing it with its own private key. The relayer broadcasts the transaction to the network. When the transaction is mined, Permit2 processes the user's signature and executes the transfer.
The relayer pays the gas. The user pays nothing. The relayer is compensated through some mechanism defined by the application, which varies by integrator. Some applications charge a fee in the token being transferred. Some subsidize the cost as a user acquisition expense. Some use a meta-transaction pattern where the relayer is repaid in a separate settlement.
The critical security property is that the relayer cannot forge the user's signature. The relayer can only submit signatures that the user already produced. If the relayer goes offline, the user can submit the signature themselves. The relayer is a convenience layer, not a trust layer, a property shared by intent-based swap execution systems. The only risk the relayer introduces is censorship, the relayer could refuse to submit the signature, but the user can always bypass the relayer and submit directly.
Nonces and Replay Protection
Permit2 uses nonces to prevent signature replay. Each permit message includes a nonce. Once a permit is processed, that nonce is marked as used. Any attempt to resubmit the same signature will revert.
Permit2 supports both sequential nonces and unordered nonces. Sequential nonces work like a counter. Each address has a nonce that increments by one after each use. This is simple but requires permits to be submitted in order. Unordered nonces use a bitmap. Each bit in a 256-bit word represents a specific nonce. This allows permits to be submitted in any order, which is important when multiple permits are signed in a single session.
The bitmap approach is more flexible for applications that batch multiple operations. A user can sign three permits with nonces 1, 5, and 200, and the relayer can submit them in any order. With sequential nonces, the relayer would need to submit them in order, and if the first one fails, the others are blocked.
Permit2 vs EIP-2612: What Changed
EIP-2612 was the first standard for gasless token approval. It added a permit function to the token contract itself. The user signs an approval message, and anyone can submit it to the token's permit function.
The problem was adoption. EIP-2612 requires the token contract to implement the function. Tokens deployed before the standard could not support it. New tokens often skipped it. The result was that only a minority of tokens supported gasless approval.
Permit2 inverts the model. Instead of requiring each token to implement permit, a single Permit2 contract provides permit functionality for all tokens. The user approves Permit2 once, and then all subsequent approvals are handled through Permit2 signatures. This works with any ERC-20 token, including tokens deployed years before Permit2 existed.
The tradeoff is the initial approval. The user must do one on-chain approve transaction to grant Permit2 an allowance. But this is a one-time cost per token. After that, every spender approval is gasless.
Permit2 Allowance Management
Permit2 introduces its own allowance system on top of ERC-20. When a user signs a permit authorizing a spender, Permit2 records an internal allowance for that spender. This allowance can be time-limited.
Permit2 supports two models. The first is single-use permits, where the permit authorizes a specific transfer of a specific amount. Once the transfer executes, the authorization is consumed. The second is allowance-based permits, where the permit grants an ongoing allowance to a spender, similar to a traditional ERC-20 approval but with an expiration.
The expiration feature is significant. Traditional ERC-20 approvals are permanent until revoked. A user who approves a spender and forgets about it leaves an open authorization indefinitely. Permit2's expiring allowances reduce this risk. An application can request an allowance that expires in one hour, one day, or one week. After expiration, the spender can no longer pull tokens.
Building a Generic Permit2 Integration
Here is a generic example of how an application integrates Permit2. This is not specific to any particular product. It shows the standard public API.
On the client side, the application constructs the permit struct and asks the wallet to sign it:
const permit = {
permitted: {
token: tokenAddress,
amount: amount.toString(),
},
nonce: nonce.toString(),
deadline: Math.floor(Date.now() / 1000) + 3600,
};
const domain = {
name: "Permit2",
version: "1",
chainId: chainId,
verifyingContract: PERMIT2_ADDRESS,
};
const types = {
PermitTransferFrom: [
{ name: "permitted", type: "TokenPermissions" },
{ name: "spender", type: "address" },
{ name: "nonce", type: "uint256" },
{ name: "deadline", type: "uint256" },
],
TokenPermissions: [
{ name: "token", type: "address" },
{ name: "amount", type: "uint256" },
],
};
const signature = await signer._signTypedData(domain, types, {
...permit,
spender: spenderAddress,
});
On the relayer side, the application receives the signature and submits it on-chain:
permit2.permitTransferFrom(
permit,
spenderSignature,
spenderAddress,
recipientAddress
);
The relayer pays gas. The user's tokens are transferred. The user never submitted a transaction.
Security Considerations
Permit2 is well-audited and widely used, but integrators should understand the security model.
The user's signature is the authorization. Anyone who obtains the signature can submit it to Permit2 before the deadline. This is by design. The signature is bearer authorization for a specific transfer. If the signature is intercepted, the attacker can front-run the intended submission. But the attacker cannot redirect the transfer, because the recipient address is encoded in the permit struct. The attacker can only cause the intended transfer to happen sooner, a limited form of the MEV extraction that plagues public mempools.
The deadline field is critical. A permit with no deadline, or a deadline far in the future, leaves the authorization open for a long window. Applications should use short deadlines, typically a few minutes to an hour, to minimize the window during which a signature could be intercepted and replayed.
The nonce prevents reuse. Once a nonce is consumed, the same signature cannot be submitted again. This protects against double-execution if a signature is somehow duplicated.
The initial ERC-20 approval to Permit2 is a one-time setup step. Users should verify they are approving the correct Permit2 contract address. On chains where Permit2 is deployed at a different address, a phony contract could be substituted. Always verify the address against the official Permit2 deployment.
Gasless Does Not Mean Free
The term gasless refers to the user's perspective. The user does not pay gas. But gas is still paid by someone. The relayer pays it, and the relayer's cost must be covered somehow.
This is an economic question, not a protocol question. Some applications absorb the cost. Some pass it on through fees. Some use a token-based subsidy. The protocol layer, Permit2 and EIP-712, is agnostic to how the relayer is compensated. It only defines how the signature is produced and verified.
Understanding this distinction matters. When you evaluate a gasless system, the question is not just how the signature works but who pays the gas and how they are repaid, a consideration that also matters when measuring the true cost of a DEX swap. The signature relay is the mechanism. The economics are the policy.
Where to Learn More
The Permit2 contract is open source and available on GitHub under the Uniswap Labs organization. The EIP-712 standard is documented in the Ethereum Improvement Proposals repository. The EIP-2612 standard is also available there for historical context.
For developers building integrations, the Permit2 SDK provides typed helpers for constructing and verifying signatures. The contract interfaces are documented in the source code with NatSpec comments. The audit reports are published alongside the repository.
These are all public resources. Nothing about Permit2 is proprietary. The protocol is designed to be a shared piece of infrastructure that any application can use, and the documentation reflects that.
Summary
Permit2 is a universal approval layer that makes token approvals gasless from the user's perspective. It works by having the user approve the Permit2 contract once, then authorizing individual spenders through EIP-712 signed messages. A relayer submits those signatures on-chain, paying the gas. The user signs but never broadcasts.
The key components are EIP-712 typed data for safe, structured signing, nonces for replay protection, deadlines for time-limited authorization, and the relayer model for gas abstraction. None of these are specific to any single application. They are public standards and open-source contracts that any developer can integrate.
If you are building an application that requires token approvals, Permit2 is worth understanding. It reduces user friction, eliminates the extra approval transaction, and provides better security properties through expiring allowances. The integration is straightforward, the contracts are audited, and the documentation is public.
Frequently Asked Questions
What is Permit2?
Permit2 is an open-source approval router contract developed by Uniswap Labs that consolidates ERC-20 token allowances behind a single contract. Instead of approving each spender individually, a user approves the Permit2 contract once and then authorizes specific spenders through signed off-chain messages. This eliminates the separate approval transaction that users normally must send before a transfer-from can succeed. Permit2 is deployed as a shared public good and any application can integrate it without permission.
How does EIP-712 typed data work?
EIP-712 defines a standard for signing typed structured data on Ethereum, replacing opaque byte-array signing with human-readable, domain-separated messages. A contract specifies a structured type definition and a verifying contract address, and the wallet displays the fields to the user in a readable format before signing. The signature binds the message to a specific contract address and chain via the EIP-712 domain separator, which prevents cross-contract and cross-chain replay. The resulting signature is verified on-chain by ecrecover after reconstructing the EIP-712 hash.
What is signature relay?
Signature relay is the pattern where a user signs an off-chain message authorizing an action, and a separate party submits that signature on-chain along with the transaction that consumes it. The user never broadcasts a transaction or pays gas; the relayer pays gas and includes the signature as a calldata argument. The on-chain contract verifies the signature against the signer's address and the authorized parameters before executing. This pattern underpins gasless approvals, meta-transactions, and intent-based architectures where signature verification precedes state changes.
Can Permit2 signatures be intercepted?
An intercepted Permit2 signature is not directly exploitable because each permit binds a specific spender, token amount, and nonce, and the signature is only valid when submitted by the designated spender. However, if an attacker can front-run the legitimate relayer and the spender is a contract the attacker controls, the authorization could be consumed. The deadline field limits the window of exposure, and the nonce prevents the same signature from being reused. Best practice is to use short deadlines and ensure the spender address is the intended contract before signing.
What happens if a Permit2 signature expires?
Once the deadline encoded in a Permit2 signature has passed, the permit is no longer valid and any transaction submitting it will revert. The signature was never consumed on-chain, so the nonce remains unused and the user can sign a fresh permit with a new deadline. No allowance is set and no tokens are at risk because the on-chain verification fails before any state changes occur. Expiration is a safety feature that bounds the exposure window of an outstanding authorization.
This is the exact pattern Orkid uses: you sign a Permit2 approval, the solver submits it and pays the gas. Try a gasless swap — or see how it compares to MetaMask Swap.
Put it to work
The research above powers the product — try it or compare it: