Skip to main content

IAllowance

Asset Tokenization Studio Team

IAllowance

Consolidated interface for the ERC-20 allowance domain: granting, reading and atomically adjusting spender allowances.

Methods​

allowance​

function allowance(address _owner, address _spender) external view returns (uint256)

Returns the remaining amount spender may spend on behalf of owner via a downstream transferFrom-style call.

Zero by default. Updated by {approve}, {increaseAllowance}, {decreaseAllowance} and by any consuming transfer operation. The returned value is time-travel adjusted at the current block timestamp on the implementing facet.

Parameters​

NameTypeDescription
_owneraddressAddress that granted the allowance.
_spenderaddressAddress authorised to spend on owner's behalf.

Returns​

NameTypeDescription
_0uint256Remaining allowance of spender over owner's tokens.

approve​

function approve(address _spender, uint256 _value) external nonpayable returns (bool)

Sets value as the allowance of spender over the caller's tokens.

Overwrites any previously-granted allowance. Known race: moving a non-zero allowance directly to another non-zero value lets spender spend both the old and the new amount via unfortunate transaction ordering — see EIP-20 discussion https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729. Prefer {increaseAllowance}/{decreaseAllowance}, or reset to zero before setting a new value. Emits {IAllowanceTypes.Approval} with the resulting allowance.

Parameters​

NameTypeDescription
_spenderaddressAddress authorised to spend on the caller's behalf.
_valueuint256Absolute allowance amount to grant.

Returns​

NameTypeDescription
_0boolBoolean flag indicating whether the operation succeeded.

decreaseAllowance​

function decreaseAllowance(address _spender, uint256 _subtractedValue) external nonpayable returns (bool)

Atomically decreases the allowance granted to spender by the caller.

Preferred alternative to {approve} as it avoids the read-modify-write allowance race. Reverts with {IAllowanceTypes.SpenderWithZeroAddress} when spender is the zero address, or with {IAllowanceTypes.InsufficientAllowance} when the current allowance is below subtractedValue. Emits {IAllowanceTypes.Approval} with the resulting allowance.

Parameters​

NameTypeDescription
_spenderaddressAddress whose allowance is being decreased.
_subtractedValueuint256Amount subtracted from the existing allowance.

Returns​

NameTypeDescription
_0boolBoolean flag indicating whether the operation succeeded.

increaseAllowance​

function increaseAllowance(address _spender, uint256 _addedValue) external nonpayable returns (bool)

Atomically increases the allowance granted to spender by the caller.

Preferred alternative to {approve} as it avoids the read-modify-write allowance race. Reverts with {IAllowanceTypes.SpenderWithZeroAddress} when spender is the zero address. Emits {IAllowanceTypes.Approval} with the resulting allowance.

Parameters​

NameTypeDescription
_spenderaddressAddress whose allowance is being increased.
_addedValueuint256Amount added to the existing allowance.

Returns​

NameTypeDescription
_0boolBoolean flag indicating whether the operation succeeded.

initializeAllowance​

function initializeAllowance() external nonpayable

Initialises the allowance capability on the token.

Callable once; subsequent calls revert with FacetAlreadyRegistered. Requires DEFAULT_ADMIN_ROLE. Called by the factory during deployment.

Events​

AllowanceInitialized​

event AllowanceInitialized()

Emitted once when the allowance capability is initialised on a token.

Fires exclusively from initializeAllowance after the storage write succeeds.

Approval​

event Approval(address indexed owner, address indexed spender, uint256 value)

Emitted when owner authorises spender to spend up to value tokens on their behalf, whether via {IAllowance.approve}, {IAllowance.increaseAllowance} or {IAllowance.decreaseAllowance}.

Mirrors the ERC-20 Approval event. value is the resulting, absolute allowance after the update — not the delta applied.

Parameters​

NameTypeDescription
owner indexedaddressAddress whose tokens may be spent.
spender indexedaddressAddress authorised to spend on owner's behalf.
valueuint256Allowance of spender over owner's tokens after the update.

Errors​

InfiniteAllowance​

error InfiniteAllowance(address owner, address spender)

Raised when an operation encounters an allowance that is effectively unlimited.

Indicates that the owner has granted the spender an infinite allowance, which may require special handling to avoid unintended accounting or revocation assumptions.

Parameters​

NameTypeDescription
owneraddressThe account that granted the allowance.
spenderaddressThe account authorised to spend on behalf of the owner.

InsufficientAllowance​

error InsufficientAllowance(address spender, address from)

Reverts when spender attempts to consume more allowance than from has granted.

Raised by transferFrom-style flows and by {IAllowance.decreaseAllowance} when the subtracted amount exceeds the current allowance.

Parameters​

NameTypeDescription
spenderaddressAddress attempting to spend on behalf of from.
fromaddressAddress whose allowance is being consumed.

SpenderWithZeroAddress​

error SpenderWithZeroAddress()

Reverts when the zero address is supplied as spender in an allowance update.