ERC-7410 Spender-initiated reduction of ERC-20 allowance (ERC-20 Update Allowance By Spender)

Draft · Tokens · created 2023-07-26

An extension standard that lets the party granted permission to use tokens (the spender) reduce or zero out their own ERC-20 allowance themselves.

Why it is needed

ERC-20 tokens have an allowance feature that lets an owner permit another address to spend a certain amount of tokens on their behalf. However, only the owner can reduce this allowance. If the owner is a corporate vault wallet or a multisignature wallet requiring multiple signers, reducing even a single excessive allowance requires consensus and a complex process, which takes a long time. Even if the permitted party wants to voluntarily give up their authority, there is no way to do so. This standard lets the permitted party reduce or revoke their own allowance from their side, adding an extra security safeguard against risks such as hacks, and allowing allowances to be cleaned up without the owner needing to go through a cumbersome process.

What to implement

In depth

Behavior of decreaseAllowanceBySpender

Contracts implementing this standard MUST implement the IERC7410 interface. decreaseAllowanceBySpender(address owner, uint256 subtractedValue) reduces the allowance that owner granted to the caller (the spender) by subtractedValue. The function MUST be public or external, and an Approval event MUST be emitted every time it is called. Because it only handles decreasing allowances rather than increasing them, a spender cannot expand their own authority, only relinquish it.

Nullification rule

If subtractedValue is equal to or greater than the current allowance, the new allowance is set to 0. This zero-setting must also apply when the current allowance is type(uint256).max (unlimited approval). In other words, under unlimited approval, calling with any value does not produce a partial reduction, it results in a full cancellation. This rule lets a spender fully cancel an allowance by passing a large value, without complex calculations.

ERC-165 Interface Identification

The ERC-165 identifier of the IERC7410 interface is 0x12860fba. The supportsInterface method MUST return true when called with 0x12860fba. Callers can use this identifier to check in advance whether a target token supports this extension. This standard assumes ERC-20 and ERC-165 (requires: 20, 165) and is compatible with existing ERC-20.

Design rationale

Allowing spenders to cancel or reduce their own allowance is a design choice that gives spenders direct control over their own level of authority. Because any subtractedValue greater than or equal to the current allowance results in 0, the implementation stays safe and the reduction procedure stays simple. The function name was chosen to resemble ERC-20's approval-related naming for consistency, so that developers familiar with ERC-20 can understand it easily.

Scenarios covered by the test cases

The reference implementation's tests verify the following: calling with a value smaller than the current allowance reduces it by exactly subtractedValue and emits an Approval event with the new allowance; calling with an equal value results in 0; calling with a larger value results in 0; calling with any value when the allowance is type(uint256).max results in 0; calling when the allowance is 0 does not fail and the allowance remains 0; and supportsInterface returns true for 0x12860fba and false for unsupported identifiers.

Proposal status

This ERC was created on July 26, 2023, and its current status is Draft. As it is still an unfinalized draft, its contents may change.

Things to watch out for

Original ERC · ← ERCs