IERC20Permit
Tokeny Solutions
IERC20Permit
Defines the ERC-2612 permit interface for signature-based ERC20 approvals.
Exposes initialisation and permit operations expected from an ERC20 permit facet. Implementations must enforce replay protection, deadline checks, and signer validity.
Methods
initializeERC20Permit
function initializeERC20Permit() external nonpayable
Initialises the ERC20 permit capability on the token.
Restricted to DEFAULT_ADMIN_ROLE by the implementation. Callable once and expected to revert with FacetAlreadyRegistered on subsequent calls. Emits ERC20PermitInitialized on success.
permit
function permit(address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external nonpayable
Approves a spender using an owner's off-chain ERC-2612 signature.
Validates the deadline, owner nonce, EIP-712 digest, and recovered signer before updating allowance. Reverts with ERC2612ExpiredSignature or ERC2612InvalidSigner when validation fails.
Parameters
| Name | Type | Description |
|---|---|---|
| _owner | address | Token holder granting the allowance. |
| _spender | address | Address authorised to spend owner tokens. |
| _value | uint256 | Allowance amount approved for spender. |
| _deadline | uint256 | Last timestamp at which the signature is valid. |
| _v | uint8 | Recovery identifier of the ECDSA signature. |
| _r | bytes32 | First 32-byte word of the ECDSA signature. |
| _s | bytes32 | Second 32-byte word of the ECDSA signature. |
Events
ERC20PermitInitialized
event ERC20PermitInitialized()
Emitted once when the ERC20 permit capability is initialised on a token.
Fires exclusively from initializeERC20Permit after successful facet registration.
Errors
ERC2612ExpiredSignature
error ERC2612ExpiredSignature(uint256 deadline)
Raised when a permit signature is submitted after its expiry deadline.
The permit must not mutate allowance state when the deadline has passed.
Parameters
| Name | Type | Description |
|---|---|---|
| deadline | uint256 | Timestamp after which the permit is no longer valid. |
ERC2612InvalidSigner
error ERC2612InvalidSigner(address signer, address owner)
Raised when the recovered permit signer does not match the token owner.
Protects approvals from invalid, malformed, or unauthorised signatures.
Parameters
| Name | Type | Description |
|---|---|---|
| signer | address | Address recovered from the submitted permit signature. |
| owner | address | Address expected to have authorised the permit. |