Appearance
Solidity API
IERC2612
Interface for the ERC2612 standard permit extension for ERC20 tokens
Implements EIP-2612: https://eips.ethereum.org/EIPS/eip-2612 This extension allows token approvals to be made via signatures (permit) rather than requiring two separate transactions (approve + transfer), saving gas and improving UX.
DOMAIN_SEPARATOR
solidity
function DOMAIN_SEPARATOR() external view returns (bytes32 domainSeparator)Returns the EIP-712 domain separator unique to the contract and chain
The domain separator is used as part of the permit signature verification process. It includes contract-specific information (name, version) and chain-specific data (chainId, contract address) to prevent signature replay attacks across different contracts or chains.
Return Values
| Name | Type | Description |
|---|---|---|
| domainSeparator | bytes32 | The 32-byte domain separator value |
nonces
solidity
function nonces(address owner) external view returns (uint256)Returns the current nonce for a given address
The nonce is incremented each time a permit is used, preventing signature replay attacks. Each owner's nonce starts at 0 and increases monotonically with each permit operation.
Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The address whose nonce is being queried |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | The current nonce value for the specified address |
permit
solidity
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) externalApproves spender to transfer tokens held by owner via signature
_Implements the EIP-2612 permit function. The signature is created using EIP-712 structured data signing. The deadline parameter helps prevent old signatures from being replayed.
The function validates:
- The deadline hasn't passed
- The signature is valid and from the token owner
- The nonce matches the owner's current nonce
After validation, it:
- Increments the owner's nonce
- Sets the approval amount for the spender_
Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The address that owns the tokens and signed the permit |
| spender | address | The address that will be approved to spend the tokens |
| amount | uint256 | The number of tokens that can be spent |
| deadline | uint256 | The timestamp after which the permit is no longer valid |
| v | uint8 | The recovery byte of the signature (ECDSA parameter) |
| r | bytes32 | The first 32 bytes of the signature (ECDSA parameter) |
| s | bytes32 | The second 32 bytes of the signature (ECDSA parameter) |