ERC20TemporaryApprovalUpgradeable
Inherits: Initializable, ERC20Upgradeable, IERC7674
Extension of {ERC20} that adds support for temporary allowances following ERC-7674. WARNING: This is a draft contract. The corresponding ERC is still subject to changes. Available since v5.1.
State Variables
ERC20_TEMPORARY_APPROVAL_STORAGE
bytes32 private constant ERC20_TEMPORARY_APPROVAL_STORAGE =
0xea2d0e77a01400d0111492b1321103eed560d8fe44b9a7c2410407714583c400;
Functions
__ERC20TemporaryApproval_init
function __ERC20TemporaryApproval_init() internal onlyInitializing;
__ERC20TemporaryApproval_init_unchained
function __ERC20TemporaryApproval_init_unchained() internal onlyInitializing;
allowance
allowance override that includes the temporary allowance when looking up the current allowance. If adding up the persistent and the temporary allowances result in an overflow, type(uint256).max is returned.
function allowance(address owner, address spender)
public
view
virtual
override(IERC20, ERC20Upgradeable)
returns (uint256);
_temporaryAllowance
Internal getter for the current temporary allowance that spender
has over owner
tokens.
function _temporaryAllowance(address owner, address spender) internal view virtual returns (uint256);
temporaryApprove
*Alternative to {approve} that sets a value
amount of tokens as the temporary allowance of spender
over
the caller's tokens.
Returns a boolean value indicating whether the operation succeeded.
Requirements:
spender
cannot be the zero address. Does NOT emit an {Approval} event.*
function temporaryApprove(address spender, uint256 value) public virtual returns (bool);
_temporaryApprove
*Sets value
as the temporary allowance of spender
over the owner
's tokens.
This internal function is equivalent to temporaryApprove
, and can be used to e.g. set automatic allowances
for certain subsystems, etc.
Requirements:
owner
cannot be the zero address.spender
cannot be the zero address. Does NOT emit an {Approval} event.*
function _temporaryApprove(address owner, address spender, uint256 value) internal virtual;
_spendAllowance
_spendAllowance override that consumes the temporary allowance (if any) before eventually falling back
to consuming the persistent allowance.
NOTE: This function skips calling super._spendAllowance
if the temporary allowance
is enough to cover the spending.
function _spendAllowance(address owner, address spender, uint256 value) internal virtual override;
_temporaryAllowanceSlot
function _temporaryAllowanceSlot(address owner, address spender) private pure returns (TransientSlot.Uint256Slot);