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 ERC7674, which proposes limiting ERC20 token approvals to a single transaction so unnecessary allowances do not remain on-chain.
This article translates, summarizes, and expands on the specification linked below. The original Mermaid diagram retains its Japanese labels.
I have also written about other EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
ERC7674 defines a minimal interface for temporarily approving (approve) ERC20 tokens within a single transaction.
Approval in this context means granting another contract permission to move a user's tokens.
With conventional ERC20 tokens, calling approve creates a persistent allowance that remains until explicitly revoked or consumed.
ERC7674 addresses this by introducing approvals that automatically expire at the end of the transaction.
The specification is designed so that the temporary approval becomes invalid as soon as the transaction ends. Users and developers therefore do not need to revoke it afterward.
Motivation
DeFi, NFT, and bridge operations involving ERC20 tokens frequently require token approvals. Many of those approvals are needed only once.
For an introduction to ERC20, see the following article.
[ERC20] An introduction to ERC20 tokens
Examples include:
- Swapping tokens once on a DEX.
- Depositing tokens into a contract once.
- Making a one-time payment to mint an NFT.
Even in these cases, conventional ERC20 approvals can remain on-chain. An unintended residual allowance can become a security risk.
Problems with persistent allowances
Residual approvals introduce several problems.
| Problem | Explanation |
|---|---|
| Security risk | A vulnerability in the approved contract could allow unauthorized token transfers. |
| Poorer user experience | Revoking an approval requires an additional transaction and gas fees. |
| More complex state management | Unused allowances remain on-chain, unnecessarily increasing the amount of state. |
Persistently storing an approval that is needed only once is therefore a poor fit for these use cases.
The role of EIP1153 and TSTORE
ERC7674 builds on the mechanism introduced by EIP1153.
EIP1153 adds transient storage to Ethereum. Transient storage has the following properties.
For an introduction to EIP1153, see the following article.
[EIP1153] Transient storage in the EVM
- Data can be stored only for the duration of a transaction.
- It is automatically cleared when the transaction ends.
- It has a lower gas cost than conventional storage writes (
SSTORE).
The relevant instruction is TSTORE.
TSTORE writes data that does not persist on the blockchain.
ERC7674 uses TSTORE to support efficient transaction-scoped token approvals.
What ERC7674 addresses
ERC7674 enables the following improvements.
- Temporary approvals automatically expire when the transaction ends.
- No separate revocation operation is needed.
- Security improves because unnecessary temporary allowances do not remain.
- Flexible token operations are possible while keeping gas costs down.
In short, ERC7674 addresses waste and risk in conventional ERC20 workflows at the token interface level. It is a practical approach for modern smart contract workflows involving many one-time operations.
Specification
Required additional function
A contract implementing ERC7674 must implement one new function alongside the existing ERC20 interface.
function temporaryApprove(address spender, uint256 value)
public
returns (bool success);Unlike the conventional approve function, this function creates a temporary approval.
Basic behavior of temporaryApprove
Calling temporaryApprove(spender, value) has the following effects.
msg.sendergrantsspenderan allowance valid only within the current transaction.spendercan calltransferFrommultiple times within that transaction.- The total amount authorized by the temporary allowance is limited to
value.
The important point is that this allowance is managed separately from the conventional, persistent ERC20 allowance.
Relationship between temporary and conventional allowances
ERC7674 allows temporary and conventional allowances to coexist.
The total allowance available to spender during the transaction is the sum of:
- The temporary allowance.
- The persistent ERC20 allowance.
In other words, the maximum amount available within the transaction is the temporary allowance plus the conventional allowance.
How allowance is consumed
The specification also defines how allowances are consumed when transferFrom is called.
ERC7674 recommends the following rules.
- Consume the temporary allowance first.
- If the temporary allowance is sufficient, do not read or update the conventional allowance.
- Consume the conventional allowance only if the temporary allowance is insufficient.
There is a reason for this design. Conventional allowances reside in persistent storage, so reading and writing them incurs gas costs. Temporary allowances exist only during the transaction, making it possible to reduce persistent storage accesses.
The flow is illustrated below.
flowchart TD
A[transferFrom 呼び出し] --> B{一時承認は十分か}
B -->|Yes| C[一時承認のみを消費]
B -->|No| D[不足分を通常承認から消費]
Lifetime of temporary approvals
A temporary allowance has a clearly defined lifetime.
- It is valid until the transaction in which it was created ends.
- It can be used multiple times within that transaction.
- It is cleared or replaced in the following cases:
- It is fully consumed by
transferFrom. - For the same
spender,temporaryApproveis called again, replacing the previous amount. - The transaction ends.
- It is fully consumed by
Most importantly, the temporary allowance is always cleared when the transaction ends. This prevents an approval from unintentionally persisting beyond the transaction.
Return value of the allowance function
Implementing ERC7674 also requires changing the return value of allowance(owner, spender).
The function must return the sum of:
- The persistent allowance.
- The temporary allowance.
It therefore accurately represents how much this spender is currently allowed to spend from an external caller's perspective.
Overflow behavior
The specification accounts for cases in which adding the temporary and conventional allowances would exceed the maximum uint256 value.
The behavior in this case is explicit.
- Return
type(uint256).max.
This is the value conventionally used to represent unlimited approval in ERC20, making the behavior intuitive for implementers and users.
Additional notes
ERC7674 minimizes its interface extension to simplify integration with existing tokens and infrastructure.
Specifically, the only new function added to ERC20 is temporaryApprove.
A minimal extension makes it easier to reuse existing wallets, SDKs, and contracts.
However, it affects the backward compatibility of the allowance function.
Under ERC7674, allowance(owner, spender) must return the sum of the persistent allowance and the temporary allowance, rather than the persistent value alone.
The implementation of transferFrom must still enforce the requirement that transfers by an explicitly approved spender are authorized. The underlying approval model therefore remains intact.
Although the meaning of allowance changes, transferFrom cannot simply move tokens without authorization; an allowance remains a prerequisite.
Compatibility
Among the ERC20 functions, only allowance changes its backward-compatible behavior.
The other operations remain backward compatible.
Here, the change in compatibility means that the value previously returned by allowance (persistent allowance only) may differ from the value returned under ERC7674 (persistent plus temporary allowance).
The following table summarizes cases that are particularly likely to be affected.
| Component | What changes | Potential problem |
|---|---|---|
UIs or analytics tools monitoring allowance(owner, spender) |
The value appears larger while a temporary allowance exists. | They may incorrectly interpret it as an increased persistent allowance, although the increase lasts only within the transaction. |
External contracts whose logic depends on allowance |
They observe a value that includes the temporary allowance. | Depending on the execution context, the observed value may differ from expectations, but only within the same transaction. |
Calls to approve, transfer, and conventional transferFrom remain supported.
The main change is the meaning of the value returned by allowance.
Reference implementation
Using transient storage
ERC7674 requires the storage location for temporary allowances to be separate from the location for regular allowances. Here, separation means not reusing the same keys or slots in a way that mixes the two kinds of allowance.
A contract implementing ERC7674 may use the transient storage introduced by EIP1153 to hold temporary allowances.
- Transient storage (EIP1153) is valid only during a transaction and is automatically cleared afterward.
- It uses the
TSTOREandTLOADinstructions. - Storing temporary allowances there is a natural fit for approvals that expire automatically.
However, careless selection of storage slots can result in collisions with slots used for other purposes.
A unique slot must therefore be selected for each combination of owner and spender.
The recommended slot derivation is:
keccak256(spender . keccak256(owner . p)).denotes byte-string concatenation.pis the result of hashing a string that uniquely identifiestemporary allowanceswithin the contract usingkeccak256.
It acts as an identifier for temporary allowance storage within the contract's namespace.
The purpose of the formula is to combine owner/spender with an identifier for the temporary allowance storage domain, reducing the risk of collisions within the same transient storage space.
Events
ERC7674 does not require an event when a temporary allowance is set. However, a compliant contract may optionally emit the following event.
event TransientApproval(
address indexed owner,
address indexed spender,
uint256 value
);An event makes it easier for wallets and indexers to observe that a temporary approval was created. On the other hand, events remain in transaction logs, increasing log volume and making activity easier to track. Making the event optional leaves this trade-off to the implementer.
Security
An important security consideration in ERC7674 is ensuring that the slot identifiers for temporary allowances do not collide with other slots in the same storage space.
Implementers must avoid the following scenarios.
- A slot used for a
temporary allowanceis also used for other data, such as a separate temporary variable or another feature'stransient storage. - As a result, the temporary allowance or the other data is overwritten.
- In the worst case, an unintended allowance amount is read and the authorization logic in
transferFromproduces an incorrect result.
The slot derivation should therefore combine owner and spender with a storage-domain identifier for the temporary allowance (p), using nested keccak256 operations to reduce collision risk.
The key points are deriving unique slots and avoiding collisions within the same storage space, such as transient storage. Without these properties, ERC7674 cannot provide temporary approvals that are safe to use within a single transaction.
Citation
Xenia Shape (@byshape), Mikhail Melnik (@ZumZoom), Hadrien Croubois (@Amxx), "ERC-7674: Temporary Approval Extension for ERC-20 [DRAFT]," Ethereum Improvement Proposals, no. 7674, April 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7674.
Conclusion
This article has covered ERC7674, a proposal for making ERC20 token approvals valid only within a single transaction, preventing unnecessary approvals from remaining on-chain. I hope it has clarified how temporary approvals work.
If you have questions, feel free to send me a direct message on Twitter.
I also publish on the following platforms.



