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.
An allowance granted through ERC20 approve remains in place after use unless the owner revokes it.
ERC8255 associates an expiration time with the amount of tokens a spender may use, while preserving existing approval operations.
Overview
When a user authorizes an application to move tokens, the approval records both the available amount and an expiration time. The spender can use the approved amount until the expiration time. After that time, it cannot use the allowance even if a positive amount remains in storage.
The same expiration condition applies to both approvals submitted directly through an interface and approvals created from a previously signed message. This reduces the period during which permissions remain active after the user has finished using an application.

Recording the approved amount and expiration together
An ERC20 approval is managed by the combination of owner, spender, and available amount.
ERC8255 adds expiration to this combination.
The expiration is the last block timestamp at which the allowance remains valid.
For example, if an owner authorizes a spender to use 100 tokens until timestamp 1,003,600, the token contract stores the amount of 100 together with the expiration of 1,003,600.
The spender may consume the allowance only within both the expiration and remaining amount constraints.
Treating the available amount as zero after expiration
There is no need to submit a transaction to delete stored data every time an approval expires.
The remaining amount that an owner has authorized a spender to move is called the allowance.
When the token contract reads the remaining amount or a spender moves tokens, it compares the stored expiration with the current timestamp. If the approval has expired, the available amount is treated as zero even if an amount remains in storage.
Expiring approvals created through signatures
An expiration time applies not only to approvals submitted directly on-chain by the owner, but also to approvals signed in advance and submitted by another sender. The deadline for submitting the signature and the expiration of the resulting allowance are managed separately.
Motivation
Ordinary ERC20 allowances have no expiration time. If the contract of an application previously used by a user is compromised, an outstanding approval from the user's wallet may be exploited.
Adding expiration alone could be accomplished through a new function.
However, if approvals created through conventional approve calls remain indefinite, users of existing wallets do not benefit from expiration protection.

Approvals remain active after use
The allowance set through ERC20 approve remains until it is exhausted through transferFrom or the owner updates it to a new value.
An approval does not automatically disappear when the user stops using the application.
ERC20 allows an owner to grant an allowance to a spender. ERC8255 adds an expiration rule to the same call.
In particular, implementations commonly treat unlimited approvals set to the maximum uint256 value as allowances that do not decrease with use.
If an integration is subsequently compromised, maliciously upgraded, or accessed through a fake frontend, old approvals can remain an attack surface for a long time.
For more about ERC20, see the following article.
[ERC20] A Beginner's Guide to ERC20
Preserving existing call patterns
Wallets and applications can continue calling approve, allowance, and transferFrom on ERC8255-compatible tokens as before.
The call formats remain unchanged, while the stored values and expiration checks inside the token contract change.
An ordinary approve uses the maximum duration defined by the token.
Applications requiring a shorter duration call the additional approveForDuration function.
Specification
The following sections distinguish the additional ERC8255 interface from the expiration semantics added to existing ERC20 functions. The standard is a draft; check the latest version before integrating it.
IERC8255
IERC8255 adds one event and three functions.
Existing approve, allowance, and transferFrom retain their interface signatures while adopting expiration-aware behavior.
ApprovalExpiration
event ApprovalExpiration(address indexed owner, address indexed spender, uint64 expiration);An event emitted when setting an expiration for an owner-spender pair. It records the owner, spender, and resulting expiration timestamp in the event log.
- Fields
| Field | Description |
|---|---|
owner |
Indexed address identifying the token owner. |
spender |
Indexed address authorized to use the tokens. |
expiration |
Approval expiration time. |
Emitting Approval is mandatory, but emitting ApprovalExpiration is optional.
Event logs are not the authoritative source of current state, and no event is emitted when an approval expires solely because time has passed. Applications must use read functions to determine current values.
The reference implementation stores the approved amount and expiration before emitting Approval and ApprovalExpiration.
This ordering is specific to the reference implementation and does not make ApprovalExpiration mandatory under the standard.
maxApprovalDuration
function maxApprovalDuration() external pure returns (uint32);Returns the maximum approval duration permitted by the token, in seconds.
The standard does not prescribe a particular duration. The token implementation selects a value within the uint32 range.
-
Retrieve the maximum duration
Retrieve the maximum duration defined by the token.
-
Apply the default duration
Use that value as the default duration for
approveandpermit. -
Validate the requested duration
For
approveForDuration, verify that the requested duration does not exceed the maximum.
- Return value
| Return value | Description |
|---|---|
| Maximum duration | Maximum duration permitted by the token. |
-
Execution conditions
-
Any address can read this value.
-
The specification does not impose a positive minimum.
-
A value of zero results in an extremely short approval, whereas the maximum
uint32value corresponds to approximately 136 years.
allowanceAndExpiration
function allowanceAndExpiration(address owner, address spender) external view returns (uint64 expiration, uint256 allowance);Returns the expiration and amount stored for an owner-spender pair. For an ordinary spender, the stored values remain accessible after expiration.
-
Read the approval information
Read the approval information corresponding to
ownerandspender. -
Decode the stored values
Recover
expirationandallowancefrom the storage representation. -
Adjust for compatibility
If an exemption for a legacy spender is active, adjust the result according to the implementation's compatibility rules.
-
Return the stored values
Return the expiration and stored amount.
- Parameters
| Parameter | Description |
|---|---|
owner |
Owner who created the approval. |
spender |
Address authorized to use the tokens. |
- Return values
| Return value | Description |
|---|---|
expiration |
Stored approval expiration. |
allowance |
Stored approved amount. |
-
Execution conditions
-
Any address can read these values.
-
For ordinary spenders, expiration does not cause the stored amount to be returned as zero.
-
To determine only the currently available amount, use
allowanceor compare the returned expiration with the current timestamp.
approveForDuration
function approveForDuration(address spender, uint256 amount, uint32 duration) external returns (bool success);Creates an expiring approval with a specified spender, amount, and duration.
If the requested duration exceeds maxApprovalDuration(), the operation fails by reverting or returning false.
-
Validate the duration
Verify that
durationdoes not exceed the token's maximum duration. -
Validate the amount
Verify that
amountcan be represented in the implementation's storage format. -
Calculate the expiration
For a nonzero approval, use
block.timestamp + durationas the expiration. -
Store the approval
Store the approved amount and expiration, and emit the required events.
-
Return success
Return
trueon success.
- Parameters
| Parameter | Description |
|---|---|
spender |
Address authorized to use the tokens. |
amount |
Amount authorized for use. |
duration |
Number of seconds from the current timestamp to expiration. |
- Return value
| Return value | Description |
|---|---|
success |
true if the approval succeeds. |
-
Execution conditions
-
The token owner calls the function to create their own approval.
-
durationmust not exceedmaxApprovalDuration(). -
Callers must treat both a revert and a
falsereturn value as failure. -
The standard provides no additional guarantees about the internal state of custom implementations that return
false.
Checking approval expiration
An approval expires when expiration < block.timestamp.
Because the comparison excludes equality, the approval is still valid when expiration == block.timestamp.

Default expiration for approve and permit
When an approve with a nonzero amount succeeds, its expiration is determined by the following formula.
expiration = block.timestamp + maxApprovalDuration();The same default duration applies to permit on an ERC8255-compatible token.
For example, if permit succeeds at timestamp 1,000,000 and the maximum duration is 86,400 seconds, the approval expires at 1,086,400.
The deadline in permit determines the latest time at which the signature may be submitted.
After a successful permit, the resulting allowance receives a separate default expiration under ERC8255.
Therefore, a signature deadline of 1,200,000 does not make the approval expire at 1,200,000.
The deadline determines when the signature may be submitted, while expiration determines how long the resulting approval may be used.
For more about ERC2612, see the following article.
[ERC2612] Executing ERC20 approve and transferFrom in One Transaction
Approvals with a zero duration
Passing zero to approveForDuration sets the expiration to the block.timestamp at which the approval is created.
Because the expiration condition uses <, the approval may still be valid for operations at the same block timestamp.
If a subsequent block has the same timestamp, the approval remains valid there as well. It expires as soon as the timestamp advances by even one second, so this mechanism cannot be treated as a guarantee of same-block-only validity.
Zero amounts and maximum amounts
An amount == 0 revokes the approval.
The available amount must become zero, and implementations are advised to clear the expiration to zero as well.
The maximum uint256 value may be treated specially as a maximum approval that is not decremented during its validity period.
However, it is not indefinite: when expiration < block.timestamp, the available amount becomes zero.
Calculating the available amount
The stored amount and the currently available amount do not necessarily match. Stored values may remain after expiration, while validity is checked during reads and consumption.
Distinguish the approved amount remaining in storage from the amount that can actually be used at the current timestamp. Even if the stored amount is 100, the actual available amount after expiration is 0.
Return value of allowance
For ordinary spenders, allowance returns a value according to the following conditions.
| Condition | Return value |
|---|---|
expiration >= block.timestamp |
Stored amount |
expiration < block.timestamp |
0 |
| Legacy spender exemption is active | Amount determined by the implementation's compatibility rules |
Expiration is not a read error.
Use allowanceAndExpiration to inspect the stored values and allowance to determine the amount currently available.
Consumption through transferFrom
transferFrom consumes the transfer amount from the available allowance after checking expiration.
If the approval has expired, the available allowance is zero, so a nonzero transfer fails.
When an ordinary allowance is partially consumed, only the remaining amount decreases; the original expiration is preserved.
In an implementation that clears the storage slot when the entire amount is consumed, the expiration may also become zero.
An implementation that treats the maximum uint256 value as a maximum approval may omit decrementing the amount during valid consumption.
The expiration check also applies to this exception.
Compatibility with legacy spenders
Implementations may offer compatibility behavior that ignores expiration for existing spenders that do not understand expiring approvals. This mechanism is optional and must be disabled by default.
An implementation may allow an administrator to designate spenders, allow spenders to designate or remove themselves, or combine both approaches. Registration interfaces and access control are outside the scope of the standard.
For a spender covered by the compatibility exemption, an implementation may return the current block timestamp as the expiration from allowanceAndExpiration.
This does not rewrite the stored expiration.
Removing the compatibility designation restores normal checks against the stored expiration.
If the stored expiration is already earlier than the current timestamp, allowance returns zero.
Event logs
When updating an approval, emit the ERC20 Approval event.
ApprovalExpiration is a supplemental event that makes expiration tracking easier, but it is optional under the standard.
No event is emitted when an approval expires simply because the clock advances.
Whether the remaining amount after transferFrom can be reconstructed from events alone also depends on the implementation's event behavior.
Indexers should use events as change notifications and resynchronize current values from allowanceAndExpiration and the current timestamp.
Contract storage and event logs should not be treated as equally authoritative sources of current state.
Packing into one storage slot
The standard describes an optional storage layout that packs expiration and amount into a single 256-bit slot.
Place expiration in the upper 64 bits and amount in the lower 192 bits.

255 192 191 0
+----------------------------------+---------------------------------------+
| expiration: 64 bits | amount: 192 bits |
+----------------------------------+---------------------------------------+The stored value can be constructed using the following expression.
packed = (uint256(expiration) << 192) | storedAmount;Ordinary amounts exceeding 192 bits can be represented using an alternative storage format. A packed implementation without an alternative representation is advised to reject intermediate values that it cannot represent.
Only the maximum uint256 value can be converted to a reserved value whose lower 192 bits are all ones.
Packing is an implementation example; ERC8255 does not guarantee a particular storage layout or a specific reduction in gas costs.
Choosing between related approaches
Expiring approvals are not the only way to reduce outstanding permissions. The choice depends on the required duration, supported tokens, and the location of the contracts that must be trusted.
Why duration is not added to permit
Adding duration to ERC2612 permit would change the signed type and function selector.
ERC8255 preserves the existing format to maintain compatibility with existing wallets and signing libraries.
After the signature, nonce, and deadline are successfully validated, the token's maxApprovalDuration() is used as the approval duration.
This compatibility behavior does not let users choose a shorter duration for each individual permit.
Comparison with approaches that leave no outstanding approval
ERC7674 confines approvals to a single transaction. For short-lived permissions spanning multiple transactions, use the duration specified through ERC8255.
ERC3009 executes a one-time token transfer using an expiring signature. It does not create an ongoing allowance, so there is no remaining approved amount.
EIP5792 is an interface for submitting multiple calls together to a wallet. When atomic execution is supported, approval, use, and revocation can be combined into one execution.
EIP7702 provides a mechanism for externally owned accounts (EOAs) to delegate execution to other code. Batch execution is implemented by the delegated code; EIP7702 itself does not specify a wallet-facing call format.
To avoid a remaining allowance during batch execution, approve only the exact amount needed or include approve(spender, 0) at the end.
If a usage window spanning multiple transactions is required, ERC8255 is an option because it can maintain the approval until expiration.
For more about ERC7674, see the following article.
[ERC7674] Temporary ERC20 Approvals
For more about EIP5792, see the following article.
[EIP5792] Wallet Call API for Batching On-Chain Calls
For more about EIP7702, see the following article.
[EIP7702] Turning an EOA into a Smart Account
For more about ERC3009, see the following article.
[ERC3009] Safer Meta-Transaction Execution
Comparison with Permit2
Permit2 relies on a prior approval from an existing token to a shared contract. That shared contract manages expiring allowances and one-time signed transfers.
Under ERC8255, the token itself returns zero for an expired allowance and causes nonzero transfers to fail. Permit2 can be integrated more easily with existing tokens, while ERC8255 changes the token's own permission model. The trusted contract and integration point differ.
Comparison with ERC5827
ERC5827Expirable adds an absolute expiration time to a replenishing allowance.
Its update rules differ from ERC8255, which makes ordinary ERC20 approvals expire by default.
An ordinary ERC8255 approval decreases by the consumed amount and does not replenish over time. ERC5827 is suited to a limit that allows a certain amount to be used repeatedly over time, while ERC8255 stops an ordinary approval at a particular timestamp.
For more about ERC5827, see the following article.
[ERC5827] ERC20 Tokens for Subscriptions and Salary Payments
Compatibility
ERC8255 preserves existing function selectors, but the results after expiration change. Compatibility of the call format must be considered separately from compatibility of behavior.
Existing ERC20 calls
Existing wallets can continue calling conventional approve.
Existing applications can also use allowance and transferFrom with the same call formats.
However, protocols that assume approvals remain valid for long periods may encounter an expired approval and a failed transferFrom at a later date.
Applications should not immediately treat this as abnormal token behavior; they should read the current values again and guide the user through a new approval.
Migrating existing storage
Legacy allowance amounts in upgradeable tokens contain no expiration information.
If read directly as packed values, legacy amounts below the maximum uint192 value can be interpreted as expired approvals with expiration == 0.
In this case, allowance can be zero while the old stored amount remains visible through allowanceAndExpiration.
If the legacy storage slot remains as a fallback read source, clear or subsequently ignore its value when a new approval, consumption, or revocation occurs.
Legacy values at or above the maximum uint192 value are split into the lower 192 bits and upper 64 bits and acquire a different meaning.
The migration specification must define whether to treat them as expired, reject them, explicitly migrate them, or convert them to the reserved maximum-approval value.
Automatically accepting a legacy maximum uint256 value as a far-future expiration creates an unintended persistent approval.
Handle it through a revert or an explicit migration process.
Integration decisions remaining in the draft
The standard does not prescribe a specific maxApprovalDuration, management permissions for the legacy spender list, or a standard mechanism for detecting support.
Because the maximum duration can be zero or approximately 136 years, the effectiveness of expiration protection varies by token.
As of October 2026, the proposed OpenZeppelin and Solady implementations are unmerged pull requests. Do not assume finalized releases or adoption across wallets. Check changes to the draft and the audit status of the implementation being used.
Application integration
ERC8255 does not define a mandatory support detection mechanism such as ERC165. Distinguish the ability to call a function from correct implementation of ERC8255 semantics.
Determining support
Applications determine support using official token information, verified source code or bytecode, and an allowlist they maintain.
A successful read call to maxApprovalDuration is only supporting evidence that the call format can be decoded.
A read call alone cannot rule out contracts that happen to share the same selector or return a value with different semantics.
Do not display a user interface that assumes approveForDuration support for a token whose compatibility has not been established.
Choosing an expiration and creating an approval
First read maxApprovalDuration() and select a duration that accommodates the application's processing time and expected mempool delays.
A duration that is too short increases failures, while one that is too long extends the risk posed by unattended approvals.
When calling from a contract, check the return value as well.
interface IERC8255Like {
function maxApprovalDuration() external view returns (uint32);
function approveForDuration(address spender, uint256 amount, uint32 duration)
external
returns (bool success);
function allowanceAndExpiration(address owner, address spender)
external
view
returns (uint64 expiration, uint256 allowance);
}
function approveWithCheckedDuration(
IERC8255Like token,
address spender,
uint256 amount,
uint32 duration
) external returns (uint64 expiration) {
require(duration <= token.maxApprovalDuration(), "duration too long");
require(token.approveForDuration(spender, amount, duration), "approval failed");
uint256 storedAmount;
(expiration, storedAmount) = token.allowanceAndExpiration(address(this), spender);
require(storedAmount == amount, "unexpected allowance");
}This example checks the upper limit first and treats both a revert and a false return value as failure.
Finally, it reads the stored values again to verify that the intended amount was recorded.
Recovering from expiration
Even if allowance is sufficient before submission, it may have expired by the block in which execution occurs.
If transferFrom fails, do not simply repeat the operation based on the stored amount.
Check the currently available amount through allowance and inspect the stored amount and expiration through allowanceAndExpiration.
If expired, request a new approval duration from the owner and resubmit the original operation after the approval succeeds.
Tests
The behavior of expiring approvals varies according to the boundary timestamp and storage representation. Test the alternative failure modes permitted by the standard separately from the behavior of a particular implementation.
Expiration boundaries
At a minimum, test the following timestamps and conditions explicitly.
| Case | Expected result |
|---|---|
block.timestamp < expiration |
Stored amount is available |
block.timestamp == expiration |
Stored amount is available |
block.timestamp == expiration + 1 |
Available amount is zero |
duration == 0 at the same block timestamp |
May be available |
duration == maxApprovalDuration() |
Success |
duration > maxApprovalDuration() |
Revert or false |
Set the block timestamp explicitly in the testing framework to avoid incidental timestamp changes during block production.
For exceeding the upper limit, specification conformance tests should accept either a revert or false, whereas tests of the reference implementation should expect a revert.
Amount consumption and maximum values
For ordinary amounts, verify that the remaining amount decreases after partial consumption while the expiration is preserved. After full consumption, verify the zero amount and expiration behavior according to whether the implementation retains or clears the storage slot.
For packed implementations, test the following boundary values separately.
| Amount | Reference implementation behavior |
|---|---|
0 |
Revokes the approval by setting amount and expiration to zero |
Maximum uint192 value - 1 |
Stored as an ordinary amount |
Maximum uint192 value |
Reverts because it conflicts with the reserved value |
Maximum uint192 value + 1 |
Reverts because there is no alternative representation |
Maximum uint256 value |
Converted to the reserved value for storage |
Verify that allowance becomes zero after expiration even for a maximum approval.
This distinguishes skipping decrements from granting an indefinite approval.
permit and legacy spenders
For permit, use different values for the signature deadline and approval expiration to verify that they are independent.
Test that the default duration is applied from the successful execution timestamp after validation of the signature, nonce, and deadline.
If legacy spender support is implemented, test administrator designation and self-designation separately. Verify the values returned during designation, that the stored expiration remains unchanged, and that normal expiration checks resume after designation is removed.
Reference implementation
The following is the core implementation for expiring allowances published in the ERC8255 specification.
Balances, total supply, transfer, the body of transferFrom, signature validation for permit, and the legacy spender list are not included. This is therefore not code that can be used as a complete ERC20 implementation as-is.

abstract contract ERC20ExpiringApprovals {
uint32 internal constant _MAX_APPROVAL_DURATION = 86400;
uint256 internal constant _AMOUNT_MASK = (uint256(1) << 192) - 1;
uint256 internal constant _MAX_AMOUNT_SENTINEL = _AMOUNT_MASK;
mapping(address owner => mapping(address spender => uint256 packed)) internal _allowances;
event Approval(address indexed owner, address indexed spender, uint256 value);
event ApprovalExpiration(address indexed owner, address indexed spender, uint64 expiration);
function maxApprovalDuration() public pure returns (uint32) {
return _MAX_APPROVAL_DURATION;
}
function allowance(address owner, address spender) public view returns (uint256) {
(uint64 expiration, uint256 amount) = allowanceAndExpiration(owner, spender);
return expiration < block.timestamp ? 0 : amount;
}
function allowanceAndExpiration(address owner, address spender)
public
view
returns (uint64 expiration, uint256 amount)
{
uint256 packed = _allowances[owner][spender];
expiration = uint64(packed >> 192);
amount = packed & _AMOUNT_MASK;
if (amount == 0) {
return (0, 0);
}
if (amount == _MAX_AMOUNT_SENTINEL) {
amount = type(uint256).max;
}
}
function approve(address spender, uint256 amount) public returns (bool) {
_approve(msg.sender, spender, amount, maxApprovalDuration());
return true;
}
function approveForDuration(address spender, uint256 amount, uint32 duration) public returns (bool) {
_approve(msg.sender, spender, amount, duration);
return true;
}
// ERC2612 implementations call this after validating the permit signature and nonce.
function _approveWithDefaultDuration(address owner, address spender, uint256 amount) internal {
_approve(owner, spender, amount, maxApprovalDuration());
}
function _approve(address owner, address spender, uint256 amount, uint32 duration) internal {
require(duration <= maxApprovalDuration(), "duration exceeds maximum");
require(
amount < type(uint192).max || amount == type(uint256).max,
"unsupported allowance"
);
uint256 expirationValue = amount == 0 ? 0 : block.timestamp + duration;
require(expirationValue <= type(uint64).max, "expiration exceeds 64 bits");
uint64 expiration = uint64(expirationValue);
uint256 storedAmount = amount == type(uint256).max ? _MAX_AMOUNT_SENTINEL : amount;
_allowances[owner][spender] = (uint256(expiration) << 192) | storedAmount;
emit Approval(owner, spender, amount);
emit ApprovalExpiration(owner, spender, expiration);
}
}Storage format and maximum duration
The first block defines the layout for a single storage slot and the default maximum duration.
uint32 internal constant _MAX_APPROVAL_DURATION = 86400;
uint256 internal constant _AMOUNT_MASK = (uint256(1) << 192) - 1;
uint256 internal constant _MAX_AMOUNT_SENTINEL = _AMOUNT_MASK;
mapping(address owner => mapping(address spender => uint256 packed)) internal _allowances;
function maxApprovalDuration() public pure returns (uint32) {
return _MAX_APPROVAL_DURATION;
}_AMOUNT_MASK is calculated by shifting 1 left by 192 bits and subtracting 1.
This sets all lower 192 bits to one, making it possible to extract only the amount from a packed value.
The same value is used for _MAX_AMOUNT_SENTINEL.
As a result, the maximum uint192 value as an ordinary amount conflicts with the maximum-approval marker and cannot be stored in the reference implementation.
The upper 64 bits of a single uint256 in _allowances[owner][spender] contain the expiration, and the lower 192 bits contain the amount.
For owner A, spender B, amount 100, and expiration 1,003,600, the stored value has the following form.
(uint256(1_003_600) << 192) | 100maxApprovalDuration() returns 86,400 seconds without reading storage.
approve and the internal function for permit use this value as their default duration, and the common _approve function uses it to validate the duration limit.
The 24-hour duration and packed layout are specific choices of the reference implementation.
These declarations and the pure function do not modify storage or emit events.
Reading stored values and the available amount
For reads, first execute allowanceAndExpiration to decode the stored values.
Then allowance determines the current available amount from the recovered expiration and amount.
function allowanceAndExpiration(address owner, address spender)
public
view
returns (uint64 expiration, uint256 amount)
{
uint256 packed = _allowances[owner][spender];
expiration = uint64(packed >> 192);
amount = packed & _AMOUNT_MASK;
if (amount == 0) {
return (0, 0);
}
if (amount == _MAX_AMOUNT_SENTINEL) {
amount = type(uint256).max;
}
}
function allowance(address owner, address spender) public view returns (uint256) {
(uint64 expiration, uint256 amount) = allowanceAndExpiration(owner, spender);
return expiration < block.timestamp ? 0 : amount;
}First read a single packed value from the mapping.
packed >> 192 moves the upper 64 bits to the rightmost position, then conversion to uint64 recovers the expiration.
packed & _AMOUNT_MASK clears the upper 64 bits and retains only the amount in the lower 192 bits.
If the recovered amount is zero, normalize the return value to (0, 0) even if an expiration remains.
If the amount is the reserved value, expand it to the maximum uint256 value only when returning it externally.
This separates the 192-bit stored value from the 256-bit value returned externally.
If the packed value is (uint256(1_003_600) << 192) | 100, allowanceAndExpiration returns expiration 1,003,600 and amount 100.
At current timestamp 1,003,600, the comparison is false, so allowance also returns 100.
When the timestamp reaches 1,003,601, expiration < block.timestamp becomes true, and allowance returns zero.
Because the packed value is unchanged, allowanceAndExpiration continues to return 1,003,600 and 100.
Both are view functions and do not revert merely because an approval has expired.
Neither modifies storage or emits events.
Three approval entry points
Approvals can be created through ordinary approve, duration-specific approveForDuration, or an internal function used after a successful permit.
All three ultimately pass the owner, spender, amount, and duration to _approve.
function approve(address spender, uint256 amount) public returns (bool) {
_approve(msg.sender, spender, amount, maxApprovalDuration());
return true;
}
function approveForDuration(address spender, uint256 amount, uint32 duration) public returns (bool) {
_approve(msg.sender, spender, amount, duration);
return true;
}
// ERC2612 implementations call this after validating the permit signature and nonce.
function _approveWithDefaultDuration(address owner, address spender, uint256 amount) internal {
_approve(owner, spender, amount, maxApprovalDuration());
}approve uses msg.sender as the owner and passes 86,400 seconds.
approveForDuration also uses msg.sender as the owner but passes the caller-specified duration.
The internal function for permit receives the owner address recovered and validated from the signature, and passes 86,400 seconds.
This internal function itself does not validate the signature, deadline, or nonce.
At timestamp 1,000,000 with amount 100, the default-duration entry points produce an expiration of 1,086,400.
If duration == 3_600, the expiration is 1,003,600.
If validation fails in the downstream _approve, the revert propagates to each entry point.
The old storage slot remains unchanged, no events are emitted, and the two public functions do not reach their true return values.
From validation to event emission
_approve performs input validation, expiration calculation, packed storage, and event emission in that order.
event Approval(address indexed owner, address indexed spender, uint256 value);
event ApprovalExpiration(address indexed owner, address indexed spender, uint64 expiration);
function _approve(address owner, address spender, uint256 amount, uint32 duration) internal {
require(duration <= maxApprovalDuration(), "duration exceeds maximum");
require(
amount < type(uint192).max || amount == type(uint256).max,
"unsupported allowance"
);
uint256 expirationValue = amount == 0 ? 0 : block.timestamp + duration;
require(expirationValue <= type(uint64).max, "expiration exceeds 64 bits");
uint64 expiration = uint64(expirationValue);
uint256 storedAmount = amount == type(uint256).max ? _MAX_AMOUNT_SENTINEL : amount;
_allowances[owner][spender] = (uint256(expiration) << 192) | storedAmount;
emit Approval(owner, spender, amount);
emit ApprovalExpiration(owner, spender, expiration);
}The first require verifies that the requested duration does not exceed the maximum.
The second require verifies that the amount is below the reserved 192-bit maximum or is the specially handled maximum uint256 value.
If the amount is zero, the expiration is also zero.
For a nonzero amount, add the duration to the current timestamp, then use the third require to verify that the result fits in uint64.
Convert to uint64 only after all validations.
Converting first would truncate high-order bits, so the order of validation and conversion is important.
Convert only the maximum uint256 value to the reserved storage value, shift the expiration left by 192 bits, and combine it with the amount using bitwise OR.
With timestamp 1,000,000, amount 100, and duration 3,600, expiration == 1_003_600 and storedAmount == 100.
The boundary values produce the following results.
amount |
Validation result | Stored content |
|---|---|---|
0 |
Success | expiration == 0, storedAmount == 0 |
Maximum uint192 value |
Failure | Prevents collision with the reserved value |
Maximum uint192 value + 1 |
Failure | Does not fit within 192 bits |
Maximum uint256 value |
Success | Converted to _MAX_AMOUNT_SENTINEL |
After storing the values, Approval records the original amount provided by the caller.
ApprovalExpiration records the expiration converted to uint64.
All three require statements precede the storage update.
If any fails, the old storage slot remains unchanged, and neither event is emitted.
No event is emitted when an approval expires solely through the passage of time.
The reference implementation emits ApprovalExpiration each time, but the event itself is optional under the standard.
Security
Expiration reduces the period during which unattended approvals can be abused. Abuse before expiration, races inherited from ERC20, compatibility exceptions, and timestamp dependencies remain and must be addressed separately.
Approval amount update race conditions
When changing a nonzero allowance to another nonzero value, a spender may still consume both the old and new allowances. Adding expiration does not resolve this race condition inherited from ERC20.
The race arises when an owner submits a transaction changing an old allowance to a new amount, and the spender can consume the old allowance before that transaction is finalized. If the new approval subsequently takes effect, the spender may move more tokens than the owner intended to authorize through the change.
A user interface may offer a process that first changes the current approval to zero, waits for confirmation, and then sets the new amount. If the sequence cannot be atomic, make clear that a race remains possible and that the spender must be trusted while the operations are pending.
Short expiration periods restrict the time during which old approvals can be used, but approval update races remain possible within that time. ERC8255 does not resolve the race itself or provide a way to recover amounts consumed by a spender before an update.
Expiration and transaction delays
Even if an application confirms that an approval is valid before submission, it may expire before the transaction is included in a block. Public mempools, network congestion, and delayed execution can increase this time difference.
If an application relies on short durations and submits transferFrom near expiration, a valid approval at transaction creation may be invalid at execution.
If expiration occurs before execution, transferFrom and subsequent operations in the same transaction revert.
The transaction sender bears the gas cost, and responsibility for resubmission depends on the application's architecture.
Choose a duration that includes expected processing delays, wallet confirmation time, and a margin for block inclusion.
Read allowance again immediately before submission and request a new approval first if the remaining time is below the required threshold.
Nevertheless, an application cannot guarantee the block inclusion timestamp. On failure, reread the available amount and expiration and provide a recovery path from renewed approval back to the original operation.
Legacy spender exemptions
Compatibility behavior for legacy spenders weakens expiration protection for the selected spenders. If such a spender is compromised, the risks associated with ordinary persistent approvals return.
A spender designated for legacy compatibility may be able to use the approved amount even after the stored expiration has passed. If many spenders are registered or registration authority is compromised, expiration no longer limits the exposure window.
Disable exemptions by default and restrict registration authority through explicit access control. Monitor designated spenders, reasons for registration, removal criteria, and change history. Remove spenders from the list when compatibility is no longer needed.
If spenders are allowed to designate themselves, also provide a way for users to inspect the exemption status. Because the registration interface and permission model are outside the standard's scope, an ERC8255 compatibility claim alone cannot guarantee safe operation of exemptions.
Storage packing and timestamps
Validate the range before converting the amount and expiration to narrower types. Type conversions without validation truncate high-order bits and can store unintended amounts or expiration times.
Truncation occurs if the upper-bound checks are omitted before converting an amount to 192 bits or an expiration to uint64.
If the expiration wraps to a small value, the approval may expire immediately. If the amount wraps to a smaller value, the stored amount no longer matches application expectations.
Before converting to the storage format, validate the representable amount range, absence of collisions with the reserved value, and whether the expiration after addition fits in uint64.
An implementation without an alternative representation should revert instead of silently truncating an amount it cannot store.
Expiration checks depend on block.timestamp.
Block producers can influence block timestamps within the consensus rules, so this mechanism should not be used to guarantee exact real-world time at the scale of a few seconds.
With short durations, timestamp differences have a relatively large effect. Allow additional time beyond the user's expected processing time.
Conclusion
ERC8255 adds an expiration condition to allowances while preserving existing ERC20 calls.
When integrating it, separately verify equality at the expiration boundary, the two time values used in permit, exemptions for legacy spenders, and migration of existing storage.
Because the standard remains a draft, track updates to both the specification and relevant libraries during implementation.
I also write articles on other platforms.




