Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ERC-2612, a standard that uses EIP-712 structured data and secp256k1 signatures to authorize ERC-20 allowances. Applications can combine a signed approval with a subsequent transfer in a single transaction.
The explanation below translates, summarizes, and expands on the original proposal.
A more accessible explanation is available in the following article.
https://chaldene.net/erc20permit
I also cover a range of other ERCs.
Overview
ERC-2612 extends ERC-20 tokens by addressing the interaction between two functions: approve and transferFrom.
Together, these functions allow applications to transfer tokens on behalf of their owners, subject to an allowance. The owner can delegate spending authority to another account or contract rather than initiating every transfer directly.
For more on ERC-20, see the following article.
Under the conventional EIP-20 design, the approve function depends on msg.sender: the token owner must call it to establish the allowance.
For an EOA interacting with an application that subsequently calls transferFrom, this generally requires two transactions unless an allowance already exists or another batching mechanism is available.
The owner also needs ETH to pay for the approval transaction.
This ERC adds a function called permit, allowing the owner to authorize changes to the allowance mapping through a signed message instead of calling approve directly.
To improve the user experience, the signed data follows EIP-712, a structured signing format supported by widely used wallets and their RPC interfaces.
When the token owner is an EOA, conventional ERC-20 approvals must be initiated by that EOA. Contract wallets can instead execute approvals as part of their own transaction logic. At the time of the original proposal, contract wallets had limited ecosystem adoption and often required applications to distinguish between the EOA controlling the wallet and the contract account holding funds. The permit pattern was proposed as a way to support signed approvals with relatively little change to existing user interfaces.
Motivation
EIP-20 tokens are widely used throughout the Ethereum ecosystem, but unlike ETH, they are implemented at the smart contract level rather than treated as native protocol assets.
The original proposal describes ERC-20 tokens as having second-class status. This refers to differences in protocol-level treatment, including the fact that ETH is the native gas payment asset.
Allowing users to interact with Ethereum without holding ETH has long been a goal discussed in several EIPs.
Many earlier proposals saw limited adoption. Others, such as EIP-777, introduced additional functionality that could cause unexpected behavior in contracts that did not account for it.
For more on ERC-777, see the following article.
[ERC-777] Understanding the Standard Token Contract Interface
ERC-2612 addresses a specific limitation of EIP-20: the inability to authorize an allowance independently of the transaction sender. It does so with a minimal extension.
One alternative would have been to introduce a separate signature-based variant for every EIP-20 function. The proposal deliberately avoids that approach for two reasons.
- The requirements for such functions vary by use case. Signature-based transfers, for example, may require different fee arrangements or batching algorithms.
- Combining
permitwith additional helper contracts allows applications to implement those use-case-specific operations without standardizing each one separately.
ERC-2612 focuses on improving the abstraction of ERC-20 approvals through a minimal change rather than defining a complete meta-transaction system.
Specification
A conforming contract must implement three additional functions alongside the EIP-20 interface.
permit
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) externalThis function updates an allowance if all the following conditions hold.
- The current block timestamp is less than or equal to the specified
deadline. - The
owneraddress is not the zero address. - The nonce included in the signed message equals the value of
nonces[owner]before the state update. - The values
r,s, andvconstitute a valid secp256k1 signature by the owner over the required message.
If any condition fails, the call must revert. On success, the allowance is set to value, the owner's nonce is incremented by one, and an Approval event is emitted.
nonces
function nonces(address owner) external view returns (uint)Returns the current nonce for the specified owner address.
DOMAIN_SEPARATOR
function DOMAIN_SEPARATOR() external view returns (bytes32)Returns the domain separator used by the contract.
The permit function authorizes token allowances subject to signature verification and other validity conditions. The nonces function exposes the owner's current nonce, while DOMAIN_SEPARATOR exposes the signing domain.
Together, these functions enable interoperable signed approvals and help prevent the reuse of signatures outside their intended scope.
keccak256(abi.encodePacked(
hex"1901",
DOMAIN_SEPARATOR,
keccak256(abi.encode(
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"),
owner,
spender,
value,
nonce,
deadline))
))The DOMAIN_SEPARATOR is defined according to EIP-712.
It should be unique to the contract and chain, helping prevent signatures from being replayed across different signing domains.
Replay attacks should not be confused with reentrancy attacks. The following article discusses the separate topic of reentrancy.
https://chaldene.net/solidity-reentrancy-attack
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes(version)),
chainid,
address(this)
));A commonly used domain separator is constructed from the following elements.
'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'- Defines the type of the signing domain.
- Its fields are:
name- The name of the signing domain, typically the token name.
version- The domain version.
chainId- The chain identifier.
verifyingContract- The verifying contract address.
keccak256(bytes(name))- Converts the name to bytes and hashes it.
keccak256(bytes(version))- Converts the version to bytes and hashes it.
chainid- The chain identifier.
address(this)- The address of the verifying contract.
These components are combined to produce the domain separator. The contract incorporates this value into the digest used for signature verification. By binding the signature to its intended contract and chain, the domain separator helps prevent cross-domain replay attacks.
Different domains normally produce different domain separators. Correct domain construction and handling of chain ID changes are important to this protection.
The domain separator identifies the context in which a signature is intended to be valid. It does not, by itself, replace nonce checks, deadline checks, or signature verification.
{
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Permit": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
}
],
},
"primaryType": "Permit",
"domain": {
"name": erc20name,
"version": version,
"chainId": chainid,
"verifyingContract": tokenAddress
},
"message": {
"owner": owner,
"spender": spender,
"value": value,
"nonce": nonce,
"deadline": deadline
}
}Notice that the signed data does not include msg.sender.
Any address may submit the permit call.
Rationale
The permit function makes it possible to build systems in which users compensate a relayer using ERC-20 tokens rather than paying transaction fees in ETH themselves.
Ethereum transaction fees are still paid in ETH at the protocol level. ERC-2612 does not change this rule; a relayer or other transaction sender can pay the gas and use a separate application-level mechanism to collect token-denominated compensation.
The nonces mapping protects against replay attacks.
A replay occurs when an existing authorization is reused. ERC-2612 assigns each owner a sequential nonce, which is incremented after every successful permit.
Once a permit has been successfully used, its signed nonce no longer matches the current nonce and the same permit cannot be used again.
A common use case involves a relayer submitting a permit on behalf of the owner.
The relayer can choose whether and when to submit the signed authorization.
However, the owner can limit this option by specifying a deadline. Once the deadline passes, the signature cannot be used to authorize an allowance.
Setting the deadline to the maximum uint256 value, historically written as uint(-1), creates an effectively non-expiring permit.
Finally, EIP-712 typed messages are used to maintain compatibility with widely adopted wallet signing mechanisms. Structured data allows wallets to display the authorization's fields and helps applications verify that a signature corresponds to the intended message.
Backward compatibility
Some token contracts already implemented functions called permit before ERC-2612 was standardized.
A prominent example is the implementation introduced in dai.sol. It differs from ERC-2612 in several respects.
- Instead of a
valueargument, it accepts a Booleanallowedand sets the allowance to either zero or the maximum uint256 value.- The flag enables or disables an effectively unlimited allowance.
- Instead of
deadline, it uses an argument calledexpiry.- This field represents the expiration of the signed permit and forms part of the signed message.
The Stake token, at Ethereum address 0x0Ae055097C6d159879521C384F1D2123D1f195e6, has a different permit implementation with the same ABI as DAI.
It supports expiring approvals, allowing transferFrom only while the approval satisfies the relevant timestamp condition.
The permit interface specified here matches the implementation used by Uniswap V2. The requirement to revert when a permit is invalid was added after implementations had already been deployed widely. Existing implementations at the time were consistent with that requirement.
Although several tokens expose a function named permit, their argument types and authorization semantics may differ. Integrators should check the actual token contract rather than assuming every implementation conforms to ERC-2612.
Security considerations
The signer of a permit usually intends it to be submitted as part of a particular transaction. However, because anyone can submit the signature, another party may front-run that transaction and execute the permit first. For the permit itself, the resulting allowance authorization is the same. No particular submitter has exclusive execution rights. An application that combines permit and another operation should nevertheless account for the possibility that the permit nonce has already been consumed.
The ecrecover precompile returns the zero address when recovery fails.
The contract must therefore check owner != address(0) to prevent invalid signatures from creating allowances associated with the zero address.
Signed permits are also subject to censorship by relayers.
After receiving a signature, a relayer may choose not to submit it.
The deadline parameter helps limit this risk by allowing the owner to specify a near-term expiration.
If the owner has ETH, the owner can also submit an appropriate permit using the same nonce to consume it and invalidate a competing, previously signed permit.
The allowance race condition associated with conventional ERC-20 approvals (SWC-114) also applies to permits.
If the domain separator includes chainId and is cached permanently at deployment, a future chain split may create a cross-chain replay risk.
A chain ID change must be handled appropriately so that signatures intended for one chain cannot be reused on another chain sharing the old cached domain separator.
Permit implementations and integrations must account for signature validity, nonce handling, allowance race conditions, relayer behavior, and domain separation.
Citation
Martin Lundfall (@Mrchico), "ERC-2612: Permit Extension for EIP-20 Signed Approvals," Ethereum Improvement Proposals, no. 2612, April 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2612.
Conclusion
ERC-2612 extends ERC-20 with EIP-712 signed approvals. By allowing a third party to submit a permit, it removes the need for a separate approval transaction from the token owner and enables applications to combine allowance authorization with a subsequent token transfer in one transaction.
If you have questions, feel free to reach out via Twitter DM.
I also publish on the following platforms.


