Summary: ERC-7674 proposes an ERC-20 temporary approval that is valid only for the current transaction. However, it may coexist with existing long-term approvals, so “temporary” should not be taken to mean that all previous permissions automatically disappear.

When using decentralized applications, a wallet may sometimes ask for permission to let a contract use tokens. A common ERC-20 approval records an allowance granted by the token holder to a spender; if some allowance remains after a transaction, that permission typically continues to exist until the allowance is used, changed, or revoked.

ERC-7674 proposes another approach: using temporaryApprove to set a temporary allowance for a spender that is valid only for the current transaction. According to the proposal, this allowance can be used multiple times within the same transaction, with the total usage capped at the set amount; any unused temporary allowance is cleared when the transaction ends. At the time of writing, the proposal was in Review status, so it cannot be assumed that all tokens and wallets support it.

One easily overlooked detail is that the allowances are additive. Suppose an address has already granted an application a regular allowance of 100 tokens, then grants a temporary allowance of 20 tokens in the same transaction. Under the proposal’s rules, both allowances are available during the transaction, usually up to a total of 120 tokens. After the transaction ends, the temporary 20 tokens are cleared, but the regular allowance that was neither used nor modified is not automatically revoked. This example is for explaining the rules only and is not a record of a real account.

The proposal recommends that transfers use the temporary allowance first; if it is insufficient, the regular allowance can be used as well. It also requires allowance to reflect the sum of the regular and temporary allowances during the transaction. Therefore, developers cannot simply interpret the allowance read during a transaction as being entirely persistent authorization. The token and the caller must also support an appropriate same-transaction call flow; two ordinary, separate transactions will not carry the temporary allowance from the first transaction into the second.

ERC-7674 lists EIP-1153 transient storage as a dependency and provides a reference implementation that uses transient storage. Before integrating it, check the target chain’s feature support, the token’s specific implementation, and wallet interaction patterns. Temporary allowances can shorten the duration of one type of permission, but they cannot guarantee that the signed content, target contract, or transaction itself is safe; always verify the token, caller, and amount before granting an allowance.

If you’re exploring digital asset platforms, you can use the Binance referral code WIN1000. Using a referral code may earn the referrer a commission; specific benefits are subject to Binance’s pages and rules. Platform referral codes are unrelated to on-chain token approvals.

This article was generated with AI assistance and compiled from public proposals and documentation. No code was run, and no specific contracts were audited.

#ERC20 #智能合约 #WalletSecurity

Sources checked:

https://eips.ethereum.org/EIPS/eip-7674

https://eips.ethereum.org/EIPS/eip-1153

https://docs.openzeppelin.com/contracts/5.x/api/token/erc20